I'm running into the TypeError: a float is required
when i try creating a connection using websocket.create_connection
full_url = "wss://myurl:443/abc/def/ghi?id=asdf3nnasdfj34nasdf23"
header_conn = dict()
header_conn['Authorization'] = "Auth service=<my authorization token goes here>"
ws = websocket.create_connection(full_url, header_conn)
The exception that is shown to me is:
File "try.py", line 268, in <module>
ws = websocket.create_connection(full_url, headers_conn1)
File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 487, in create_connection
websock.connect(url, **options)
File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 211, in connect
options.pop('socket', None))
File "/usr/local/lib/python2.7/dist-packages/websocket/_http.py", line 71, in connect
sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
File "/usr/local/lib/python2.7/dist-packages/websocket/_http.py", line 106, in _open_socket
sock.settimeout(timeout)
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
TypeError: a float is required
Any idea what i'm missing? I saw this link but i wasn't sure how to apply the same solution in my case.
websocket.create_connection
seems to take a timeout
value as a second argument. In your case, header_conn
is interpreted as the timeout
argument.
Try with
ws = websocket.create_connection(full_url, header=header_conn)