“TypeError: a float is required” occurred when using websocket
“TypeError: a float is required” occurred when using websocket
当我尝试使用 websocket.create_connection
创建连接时,我 运行 进入了 TypeError: a float is required
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)
向我显示的异常是:
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
知道我错过了什么吗?我看到 this link 但我不确定如何在我的案例中应用相同的解决方案。
websocket.create_connection
似乎将 timeout
值作为第二个参数。在您的情况下,header_conn
被解释为 timeout
参数。
试试
ws = websocket.create_connection(full_url, header=header_conn)
当我尝试使用 websocket.create_connection
TypeError: a float is required
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)
向我显示的异常是:
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
知道我错过了什么吗?我看到 this link 但我不确定如何在我的案例中应用相同的解决方案。
websocket.create_connection
似乎将 timeout
值作为第二个参数。在您的情况下,header_conn
被解释为 timeout
参数。
试试
ws = websocket.create_connection(full_url, header=header_conn)