hretic
hretic

Reputation: 1095

python signalR - 500 Server Error when trying to connect

i trying to connect to a signalR api using this lib

https://pypi.org/project/signalr-client/

here is my code

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()

but i get this error

$ 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

Upvotes: 6

Views: 729

Answers (2)

Mohammad Namakshenas
Mohammad Namakshenas

Reputation: 85

You should use omsclienttokenhub instead of GetNewAPIToken for registering the hub. You should also change signalr into signalr_aio.

cheers.

Upvotes: 0

nathancy
nathancy

Reputation: 46670

I am unable to reproduce your error. The problem may be due to corrupted or outdated packages, maybe a fresh install will solve your problem. The SignalR library is dependent on these packages

certifi, idna, chardet, urllib3, requests, websocket-client, greenlet, pycparser, cffi, gevent, sseclient, signalr-client

To do a fresh install, first uninstall the packages

python -m pip uninstall -y certifi, idna, chardet, urllib3, requests, websocket-client, greenlet, pycparser, cffi, gevent, sseclient, signalr-client

Then to reinstall

python -m pip install certifi, idna, chardet, urllib3, requests, websocket-client, greenlet, pycparser, cffi, gevent, sseclient, signalr-client --upgrade

Upvotes: 1

Related Questions