【发布时间】:2017-06-06 18:07:42
【问题描述】:
我一直在尝试使用 python websocket-client 模块来接收和存储来自交换的持续更新。一般情况下,脚本会顺利运行一天左右,然后报如下错误:websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed。
我查看了 websocket-client 源代码,显然代码 if not bytes_: 在第 92 行引发了错误。此外,WebSocketConnectionClosedException 应该被提升为"If remote host closed the connection or some network error happened"。
谁能告诉我为什么会发生这种情况,以及我可以做些什么来阻止或处理它。
【问题讨论】:
-
请给我们一些代码。
-
表示有人关闭了连接。你能重新建立它吗?我认为无论如何你都需要它来恢复弹性。
-
你有没有找到解决这个问题的方法?我遇到了同样的问题。
-
我想知道如何重现这个错误,因为这花了我很多钱。我认为添加一个检查,例如:try: ws.close() except: pass finally: self.connect() 会起作用,但 idk 还没有