2017-09-14 98 views
0

當我跑步到TypeError: a float is required當我嘗試創建一個使用websocket.create_connection「類型錯誤:一個浮動需要」使用的WebSocket

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鏈接,但我不確定如何在我的情況下應用相同的解決方案。

回答

1

websocket.create_connection似乎需要timeout值作爲第二個參數。在你的情況下,header_conn被解釋爲timeout的論點。

嘗試用

ws = websocket.create_connection(full_url, header=header_conn) 
相關問題