我试图使用此库连接到signalR api
https://pypi.org/project/signalr-client/
这是我的代码
from requests import Session
from signalr import Connection
with Session() as session:
#create a connection
connection = Connection("https://firouzex.exphoenixtrade.com/realtime", session)
#get chat hub
chat = connection.register_hub('GetNewAPIToken')
#start a connection
connection.start()
但我得到这个错误
$ python test.py
Traceback (most recent call last):
File "test.py", line 12, in <module>
connection.start()
File "C:\Users\Rooz\AppData\Local\Programs\Python\Python35\lib\site-packages\signalr\_connection.py", line 47, in start
negotiate_data = self.__transport.negotiate()
File "C:\Users\Rooz\AppData\Local\Programs\Python\Python35\lib\site-packages\signalr\transports\_auto_transport.py", line 16, in negotiate
negotiate_data = Transport.negotiate(self)
File "C:\Users\Rooz\AppData\Local\Programs\Python\Python35\lib\site-packages\signalr\transports\_transport.py", line 28, in negotiate
negotiate.raise_for_status()
File "C:\Users\Rooz\AppData\Local\Programs\Python\Python35\lib\site-packages\requests\models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://firouzex.exphoenixtrade.com/realtime/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A+%22GetNewAPIToken%22%7D%5D
最佳答案
我无法重现您的错误。该问题可能是由于软件包损坏或过时造成的,也许全新安装将解决您的问题。 SignalR
库依赖于这些软件包
certifi, idna, chardet, urllib3, requests, websocket-client, greenlet, pycparser, cffi, gevent, sseclient, signalr-client
要进行全新安装,请先卸载软件包
python -m pip uninstall -y certifi, idna, chardet, urllib3, requests, websocket-client, greenlet, pycparser, cffi, gevent, sseclient, signalr-client
然后重新安装
python -m pip install certifi, idna, chardet, urllib3, requests, websocket-client, greenlet, pycparser, cffi, gevent, sseclient, signalr-client --upgrade
关于python signalR-尝试连接时出现500服务器错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56725738/