我尝试使用以下代码连接到Pusher:https://github.com/nlsdfnbch/Pysher/
import pysher
# Add a logging handler so we can see the raw communication data
import logging
root = logging.getLogger()
root.setLevel(logging.INFO)
ch = logging.StreamHandler(sys.stdout)
root.addHandler(ch)
pusher = pysher.Pusher('de504dc5763aeef9ff52')
# We can't subscribe until we've connected, so we use a callback handler
# to subscribe when able
def connect_handler(data):
channel = pusher.subscribe('live_trades')
channel.bind('trade', callback)
pusher.connection.bind('pusher:connection_established', connect_handler)
pusher.connect()
while True:
# Do other things in the meantime here...
time.sleep(1)不是一些有效的回复,而是每隔几秒钟就会收到这样的信息:
连接:错误- WinError 10042在getsockopt或setsockopt调用连接中指定了未知、无效或不受支持的选项或级别:连接关闭,试图在10秒内再次连接。
有什么问题吗?
发布于 2018-08-15 19:41:11
使用使用websockets的不同库时,我看到了相同的错误。我可以从您的描述(和链接)中看到Pysher使用websockets。
我发现(又一个)用于Python的websocket客户端报告了websocket的一个问题,特别是Python3.6.4:[https://github.com/websocket-client/websocket-client/issues/370]。
它还引用了Python中的bug以及[https://bugs.python.org/issue32394]。
升级到Python3.6.5为我工作。或者,他们建议升级到Windows10 1703+也应该有效(只是为了完整性,我还没有验证这一点)。
https://stackoverflow.com/questions/47962516
复制相似问题