Python错误10042 Pusher Web

2024-09-29 05:29:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用以下代码连接到Pusher Websocket API: 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)

我每隔几秒钟就会收到这样的回复:

Connection: Error - [WinError 10042] An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call Connection: Connection closed Attempting to connect again in 10 seconds.

有什么问题吗?在


Tags: orinimportsologgingconnectrootconnection
1条回答
网友
1楼 · 发布于 2024-09-29 05:29:55

我在使用另一个使用websockets的库时看到了相同的错误。从你的描述(和链接)中我可以看出Pysher使用websockets。在

我发现(又一个)Python的websocket客户端报告了websockets的问题,特别是python3.6.4:[https://github.com/websocket-client/websocket-client/issues/370]

它还引用了pythontracker中的bug[https://bugs.python.org/issue32394]

升级到python3.6.5对我很有用。或者,他们建议升级到Windows101703+也可以(只是为了完整性;我还没有验证这一点)。在

相关问题 更多 >