MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    mirai-api-http中通过websocket获取消息的延迟非常大

    开发交流
    3
    10
    291
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      Jadlokin-Scarlet last edited by

      我在另一台服务器通过http-api的websocket接口请求mirai获取即时的聊天消息。
      从我在QQ中发送消息到通过接口获取到消息有几十秒的延迟。
      是否是因为mirai已经部署了一个月导致缓存过多的原因,或是其他的原因。
      我应该如何改善。

      补充信息(有需要我再补充):

      1. mirai-api-http版本为1.10.0,websocket文档:
        https://github.com/project-mirai/mirai-api-http/blob/master_1.x/docs/API.md#通过websocket
      2. 通过countMessage接口获取到的缓存消息数为0。{"code":0,"errorMessage":"","data":0}
      3. 我的api-http配置文件:
      cors: 
        - '*'
      host: 0.0.0.0
      port: ****
      authKey: ********
      cacheSize: 4096
      enableWebsocket: true
      report: 
        enable: true
        groupMessage: 
          report: true
        friendMessage: 
          report: true
        tempMessage: 
          report: true
        eventMessage: 
          report: true
        destinations: []
        extraHeaders: {}
      
      heartbeat: 
        enable: true
        delay: 1000
        period: 15000
        destinations: []
        extraBody: {}
      
        extraHeaders: {}
      
      1 Reply Last reply Reply Quote 0
      • RainChan
        RainChan 摸鱼 last edited by

        @ryoii

        1 Reply Last reply Reply Quote 0
        • ryoii
          ryoii 梦中的鸡翅 last edited by

          检查发消息之后mirai console是否及时出现消息的日志

          J 1 Reply Last reply Reply Quote 0
          • J
            Jadlokin-Scarlet @ryoii last edited by

            @ryoii 是的,发消息之后mirai console及时出现消息的日志

            1 Reply Last reply Reply Quote 0
            • ryoii
              ryoii 梦中的鸡翅 last edited by

              不太像是缓存的原因

              J 1 Reply Last reply Reply Quote 0
              • J
                Jadlokin-Scarlet @ryoii last edited by

                @ryoii 有什么办法解决吗_(:з」∠)_
                我尝试了重启mirai,但是没能缓解延迟

                1 Reply Last reply Reply Quote 0
                • ryoii
                  ryoii 梦中的鸡翅 last edited by

                  重启也不能解决?那就更怪了

                  J 1 Reply Last reply Reply Quote 0
                  • J
                    Jadlokin-Scarlet @ryoii last edited by

                    @ryoii 我收到pong后会在一分钟后发出ping消息,这是否是问题所在

                    1 Reply Last reply Reply Quote 0
                    • J
                      Jadlokin-Scarlet last edited by

                      是的,这是问题所在,我取消了这段逻辑,他不再有几十秒的延迟,但这是为什么。
                      另外我之所以这么做是因为如果不持续ping的话,会因为session key过期而关闭连接。
                      有没有既可以维持连接,又不会有延迟的解决方案。

                      1 Reply Last reply Reply Quote 0
                      • ryoii
                        ryoii 梦中的鸡翅 last edited by ryoii

                        1.x 如果启用 websocket 是不会有 sessionKey 过期的

                        但是有 issue 反映10分钟无响应的 socket 会导致 socket 无响应,但是这不是代码的逻辑,且我也没有复现

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact