flutter - Websocket 在 Flutter web 上完全断开连接
问题描述
我们有一个与推送器 websocket 的连接。我们每 40 秒发送一次 ping 消息。
正在使用的库:https ://pub.dev/packages/web_socket_channel
当发生断开连接时,我们正在登录控制台。
它考虑到onDone
这里的事件
_subscription = _channel!.stream.listen(
(e) => _handlePusherEvent(e, id),
onDone: () => _onDone(message: 'onDone'), // Erratic clean disconnection here
onError: (e) => _onWebsocketError(e),
);
void _onDone({required String message}) {
print(message);
}
行为不稳定,有时会在 7 小时后完成,有时只需几分钟。我们正在记录 ping 和 pong 消息。ping 消息日志在onDone
事件之前,因此它不会因为没有发送 ping 消息而被关闭。
这是推动者方面的一些问题吗?
谢谢
解决方案
推荐阅读
- java - 如何使用 aws-sdk-java JmesParser 过滤 JSON
- python - 运行 python 文件时出错(无法导入 psycopg2)
- javascript - 使用 JS 或 jQuery 从 URL 获取参数
- python - 在python中将QUIT函数应用于迷你游戏
- python - 创建轨迹栏以滚动大图像和上下边界(Pyhton / OpenCV)
- android - 如何在 MPAndroidChart 饼图中的标记视图中显示值标签?
- actionscript-3 - Adobe Flash Builder:如何制作带有进度条的 SWF 用于加载自身?
- javascript - 使用未发送到正文的文件上传来反应js fetch api
- python - 正则表达式检查字符串是代表 5 位还是 6 位数字
- git - 如何在一个 sourceforge 项目中创建多个 git 存储库