Skip to content

[Bug]: HTTP API 使用 SSE 推送的消息有遗漏 #685

@gengyunmaster

Description

@gengyunmaster

提交前确认

  • 我已搜索过现有的 Issues,确认这不是重复问题
  • 我使用的是最新版本
  • 我已阅读过相关文档

使用平台

Windows

问题严重程度

边缘场景或轻微问题(等待空闲时修复)

问题描述

并非所有新收到的微信消息都会被 SSE 推送,具体来说涉及两方面问题:

  • 有时候来自好友或群的消息未被 SSE 推送,特别是短时间内接收到较多条来自好友或群的消息时遗漏的概率很大,这应该是程序的 bug;
  • 来自非好友或群的消息(如公众号、微信支付、服务通知等的消息)不会被 SSE 推送,这些也属于消息的范畴,理应被推送,这应该是程序的功能缺陷。

复现步骤

  1. 在“设置”中开启 HTTP API ;
  2. 开启 SSE ;
  3. 使用任意 SSE 客户端连接 SSE 服务端(即 WeFlow ),比如这里给出一个简单的 Python 实现(实际上使用任意 SSE 客户端均可):
import requests
import time

def sse_client_demo():
    url = "http://127.0.0.1:5031/api/v1/push/messages"
    headers = {
        "Accept": "text/event-stream",
        "Cache-Control": "no-cache",
        "Connection": "keep-alive"
    }
    print(f"正在连接 SSE 服务端: {url}")
    print("等待接收消息...\n")
    try:
        response = requests.get(url, headers=headers, stream=True)
        for line in response.iter_lines():
            if line:
                msg = line.decode('utf-8')
                print(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] 收到消息:")
                print(msg)
                print("-" * 50)
    except requests.exceptions.ConnectionError:
        print("错误:无法连接服务端,请确认服务已启动!")
    except KeyboardInterrupt:
        print("\n已手动断开连接")
    except Exception as e:
        print(f"异常:{str(e)}")

if __name__ == "__main__":
    sse_client_demo()
  1. 在短时间内接收大量来自好友或群的消息,会发现有个别消息未被 SSE 推送;
  2. 接收来自非好友或群的消息,会发现这些消息未被 SSE 推送。

预期行为

任何消息都可以被不遗漏地通过 SSE 推送。

实际行为

见上方“问题描述”。

错误日志或截图

操作系统版本

Windows 11 24H2

应用版本

v4.2.1

系统架构

x64

补充信息

No response

Metadata

Metadata

Assignees

Labels

status: needs info缺少复现步骤或报错日志,等待提问者补充type: bug代码问题

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions