TargetProcess / signalr-client-py

python client proxy for signalr
Other
63 stars 58 forks source link

AttributeError: 'NoneType' object has no attribute 'get' #47

Open WojciechTeodorowicz opened 6 years ago

WojciechTeodorowicz commented 6 years ago

I am getting the following error when i run my code AttributeError: 'NoneType' object has no attribute 'get'

from requests import Session
from signalr import Connection

def main():
    with Session() as session:
        connection = Connection("http://localhost:8089/signalr", session=None)
        presenceservice = connection.register_hub('MyHub')
        key = input("Press E\n")
        while connection:
            if key == 'e':
                 presenceservice.server.invoke('Heartbeat')  
                 presenceservice.client.on('Heartbeat', print("Recieved Heartbeat \n"))

if __name__ == "__main__":
    main()

Log

Traceback (most recent call last):
  File "C:/Users/user/AppData/Local/Programs/Python/Python37/signalrr.py", line 19, in <module>
    main()
  File "C:/Users/user/AppData/Local/Programs/Python/Python37/signalrr.py", line 10, in main
    connection.start()
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\signalr\_connection.py", line 47, in start
    negotiate_data = self.__transport.negotiate()
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\signalr\transports\_auto_transport.py", line 16, in negotiate
    negotiate_data = Transport.negotiate(self)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\signalr\transports\_transport.py", line 26, in negotiate
    negotiate = self._session.get(url)
AttributeError: 'NoneType' object has no attribute 'get'
ngunhaSO commented 5 years ago

You need to pass in the session when you initialize the connection: connection = Connection("http://localhost:8089/signalr", session)