summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliris <liris.pp@gmail.com>2019-12-25 21:15:45 +0900
committerGitHub <noreply@github.com>2019-12-25 21:15:45 +0900
commit0b99f62e2871df0d498fd324d5b9b629a4b4ee9f (patch)
treefa99182d47735d9e930715cbdea11e81ff4d8499
parentbc4ab2eb791233e46e5f71b7944746bbaafc303b (diff)
parent6b69bc210e3a19ad39110906210044a6e8d9abf9 (diff)
downloadwebsocket-client-0b99f62e2871df0d498fd324d5b9b629a4b4ee9f.tar.gz
Merge pull request #573 from devmonkey22/master
Resolve issue opening socket to intranet on Windows 10 with no proxy settings but behind proxy
-rw-r--r--websocket/_http.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/websocket/_http.py b/websocket/_http.py
index 7068c6c..29a699c 100644
--- a/websocket/_http.py
+++ b/websocket/_http.py
@@ -138,16 +138,15 @@ def _get_addrinfo_list(hostname, port, is_secure, proxy):
phost, pport, pauth = get_proxy_info(
hostname, is_secure, proxy.host, proxy.port, proxy.auth, proxy.no_proxy)
try:
+ # when running on windows 10, getaddrinfo without socktype returns a socktype 0.
+ # This generates an error exception: `_on_error: exception Socket type must be stream or datagram, not 0`
+ # or `OSError: [Errno 22] Invalid argument` when creating socket. Force the socket type to SOCK_STREAM.
if not phost:
addrinfo_list = socket.getaddrinfo(
- hostname, port, 0, 0, socket.SOL_TCP)
+ hostname, port, 0, socket.SOCK_STREAM, socket.SOL_TCP)
return addrinfo_list, False, None
else:
pport = pport and pport or 80
- # when running on windows 10, the getaddrinfo used above
- # returns a socktype 0. This generates an error exception:
- #_on_error: exception Socket type must be stream or datagram, not 0
- # Force the socket type to SOCK_STREAM
addrinfo_list = socket.getaddrinfo(phost, pport, 0, socket.SOCK_STREAM, socket.SOL_TCP)
return addrinfo_list, True, pauth
except socket.gaierror as e: