Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 跨日时抛出异常 BiliApiError: bad timestamp request #205

Open
3 tasks done
cyb233 opened this issue Nov 27, 2024 · 2 comments · May be fixed by #211
Open
3 tasks done

[Bug]: 跨日时抛出异常 BiliApiError: bad timestamp request #205

cyb233 opened this issue Nov 27, 2024 · 2 comments · May be fixed by #211

Comments

@cyb233
Copy link
Contributor

cyb233 commented Nov 27, 2024

请确保您已阅读以上注意事项,并勾选下方的确认框。

  • 我已经仔细阅读上述教程和 "提问前需知"
  • 我已经在 Issue Tracker 中找过我要提出的问题,没有找到相同问题的ISSUE。
  • 我已知晓并同意,此处仅用于汇报程序中存在的问题。若这个 Issue 是关于其他非程序本身问题,则我的 Issue 可能会被无条件自动关闭或/并锁定。

粉丝牌助手 版本

#204

运行环境

Windows (64)

运行架构

None

部署方式

本地

粉丝牌数量

共148个,其中需要观看的有129个

日志记录(可选)

2024-11-28 00:00:02.932 | ERROR    | __main__:main:109 - bad timestamp request,timestamp:1732723142,watchtime:60
Traceback (most recent call last):

  File "C:\Users\Administrator\Desktop\fansMedalHelper\main.py", line 177, in <module>
    loop.run_until_complete(main())
    │    │                  └ <function main at 0x0000023AF158F9C0>
    │    └ <function BaseEventLoop.run_until_complete at 0x0000023AF1401760><ProactorEventLoop running=True closed=False debug=False>

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 674, in run_until_complete
    self.run_forever()
    │    └ <function ProactorEventLoop.run_forever at 0x0000023AF14ED620><ProactorEventLoop running=True closed=False debug=False>
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\windows_events.py", line 322, in run_forever
    super().run_forever()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 641, in run_forever
    self._run_once()
    │    └ <function BaseEventLoop._run_once at 0x0000023AF14034C0><ProactorEventLoop running=True closed=False debug=False>
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 1986, in _run_once
    handle._run()
    │      └ <function Handle._run at 0x0000023AEFB69120><Handle Task.task_wakeup(<_GatheringFu...atchtime:60')>)>
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
    │    │            │    │           │    └ <member '_args' of 'Handle' objects>
    │    │            │    │           └ <Handle Task.task_wakeup(<_GatheringFu...atchtime:60')>)>
    │    │            │    └ <member '_callback' of 'Handle' objects>
    │    │            └ <Handle Task.task_wakeup(<_GatheringFu...atchtime:60')>)>
    │    └ <member '_context' of 'Handle' objects><Handle Task.task_wakeup(<_GatheringFu...atchtime:60')>)>

> File "C:\Users\Administrator\Desktop\fansMedalHelper\main.py", line 107, in main
    await asyncio.gather(*startTasks)
          │       │       └ [<coroutine object BiliUser.start at 0x0000023AF26AAB60>]
          │       └ <function gather at 0x0000023AF13EE0C0><module 'asyncio' from 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\asyncio\\__init__.py'>

  File "C:\Users\Administrator\Desktop\fansMedalHelper\src\user.py", line 190, in start

  File "C:\Users\Administrator\Desktop\fansMedalHelper\src\user.py", line 250, in watchinglive
    if heartNum%5==0:
       └ 22

  File "C:\Users\Administrator\Desktop\fansMedalHelper\src\api.py", line 427, in heartbeat
    ),

  File "C:\Users\Administrator\Desktop\fansMedalHelper\src\api.py", line 72, in wrapper
    raise e

  File "C:\Users\Administrator\Desktop\fansMedalHelper\src\api.py", line 61, in wrapper
    result = await func(*args, **kwargs)
                   │     │       └ {'data': {'access_key': '*', 'actionKey': 'appkey', 'appkey': '4409e2ce8ffd12b8', 'area_id': '...
                   │     └ (<src.api.BiliApi object at 0x0000023AF26F0F80>, 'https://live-trace.bilibili.com/xlive/data-interface/v1/heartbeat/mobileHea...
                   └ <function BiliApi.__post at 0x0000023AF1ACB380>

  File "C:\Users\Administrator\Desktop\fansMedalHelper\src\api.py", line 136, in __post
    async with self.session.post(*args, **kwargs) as resp:
               │    │       │     │       │          └ <ClientResponse(https://live-trace.bilibili.com/xlive/data-interface/v1/heartbeat/mobileHeartBeat) [200 OK]>
               │    │       │     │       │            <CIMultiDictProx...
               │    │       │     │       └ {'data': {'access_key': '*', 'actionKey': 'appkey', 'appkey': '4409e2ce8ffd12b8', 'area_id': '...
               │    │       │     └ ('https://live-trace.bilibili.com/xlive/data-interface/v1/heartbeat/mobileHeartBeat',)
               │    │       └ <function ClientSession.post at 0x0000023AF1AC8180>
               │    └ <aiohttp.client.ClientSession object at 0x0000023AF149DCD0><src.api.BiliApi object at 0x0000023AF26F0F80>

  File "C:\Users\Administrator\Desktop\fansMedalHelper\src\api.py", line 125, in __check_response
    if resp["code"] != 0 or ("mode_info" in resp["data"] and resp["message"] != ""):
       │                                    │                └ {'code': 1012003, 'message': 'bad timestamp request,timestamp:1732723142,watchtime:60', 'ttl': 1, 'data': None}
       │                                    └ {'code': 1012003, 'message': 'bad timestamp request,timestamp:1732723142,watchtime:60', 'ttl': 1, 'data': None}
       └ {'code': 1012003, 'message': 'bad timestamp request,timestamp:1732723142,watchtime:60', 'ttl': 1, 'data': None}

src.api.BiliApiError: bad timestamp request,timestamp:1732723142,watchtime:60

补充说明(可选)

相关情况:

  1. 我使用的是我Fork的版本,主要调整了日志输出,且确认修改与问题原因无关
  2. 通过计划任务程序每日00:05运行,计划配置见下方
  3. 未设置黑白名单,24小时不足以处理全部牌子
  4. Time.is比较,服务器时间无误差您的系统时间准确无误!与 Time.is 的时间差是 +0.029 秒钟(±0.208 秒钟)。
  5. 问题稳定每天发生,仅发生于换日时,抛出异常后使程序结束,且会在推送中记为任务执行失败
  6. 相关issues均以查看,未确认有效的解决方案
  1. 希望增加配置,在0点(或指定时间)结束任务并推送

计划任务程序配置:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2024-11-10T09:06:40.8407264</Date>
    <Author>**********\Administrator</Author>
    <URI>\fansMedalHelper</URI>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2024-11-10T00:05:00</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-21-3152784632-3446170954-2473191918-500</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>"C:\Users\Administrator\AppData\Local\Programs\Python\Python312\python.exe"</Command>
      <Arguments>"C:\Users\Administrator\Desktop\fansMedalHelper\main.py"</Arguments>
    </Exec>
  </Actions>
</Task>
@cyb233 cyb233 linked a pull request Dec 6, 2024 that will close this issue
@Malus-Mill
Copy link

同出现了该问题

@cyb233
Copy link
Contributor Author

cyb233 commented Feb 17, 2025

同出现了该问题

在开发合并或处理前,可以先用我fork的版本,里面合并了我提的几个pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants