我试图通过websocket地址连接,但我的脚本在数据恢复时出错。你知道吗
import requests
from websocket import create_connection
def conWs():
ws = create_connection('wss://olymptrade.com/ds/v3')
#ws.send('[{"t":1,"e":105,"d":[{"source":"platform"}]}]')
#ws.send('[{"t":2,"e":90,"uuid":"JR20G7HQ62P0DURZO6F"}]')
print(ws.connected)
while True:
result = ws.recv()
print ("Received '%s'" % result)
我原以为它会连接并开始接收websocket数据,但脚本中断并出现以下错误:
websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed.
看起来你需要使用不同的方法。你知道吗
看看长寿命连接的例子in the docs,请告诉我这些修改是否适用于您。祝你好运!你知道吗
相关问题 更多 >
编程相关推荐