Commit a51edc97 authored by Pascal Engélibert's avatar Pascal Engélibert

Handle socket.gaierror & connection timeout

parent 56c64b98
......@@ -519,7 +519,7 @@ class ClientThread(Thread):
logPrint("Ask "+str(peer), LOG_TRACE)
try:
header, content = sdata((peer.host, peer.port), "POST", "/list/new/"+self.keys.pubkey, message, proxy=self.conf["client"]["proxy"], proxy_onion_only=self.conf["client"]["proxy_onion_only"]) # Send
except (ConnectionRefusedError, socks.GeneralProxyError):
except (ConnectionRefusedError, socks.GeneralProxyError, socket.gaierror, socket.timeout):
peer.up = False
logPrint("Down "+str(peer), LOG_TRACE)
continue
......@@ -654,7 +654,7 @@ class ClientThread(Thread):
peer.up = True
logPrint("Sent "+tx.sender_pubkey[:8]+" -> "+tx.receiver_pubkey[:8]+" = "+str(tx.in_amount)+":"+str(tx.in_base)+" -> "+str(tx.out_amount)+":"+str(tx.out_base), LOG_TRACE)
logPrint("Up "+str(peer), LOG_TRACE)
except (ConnectionRefusedError, socks.GeneralProxyError):
except (ConnectionRefusedError, socks.GeneralProxyError, socket.gaierror, socket.timeout):
peer.up = False
logPrint("Down "+str(peer), LOG_TRACE)
except (ubjson.decoder.DecoderException, KeyError, AssertionError):
......@@ -678,7 +678,7 @@ class ClientThread(Thread):
peer.up = True
logPrint("Confirmed "+tx.sender_pubkey[:8]+" -> "+tx.receiver_pubkey[:8]+" = "+str(tx.in_amount)+":"+str(tx.in_base)+" -> "+str(tx.out_amount)+":"+str(tx.out_base), LOG_TRACE)
logPrint("Up "+str(peer), LOG_TRACE)
except (ConnectionRefusedError, socks.GeneralProxyError):
except (ConnectionRefusedError, socks.GeneralProxyError, socket.gaierror, socket.timeout):
peer.up = False
logPrint("Down "+str(peer), LOG_TRACE)
except (ubjson.decoder.DecoderException, KeyError, AssertionError):
......
......@@ -65,7 +65,9 @@ def sdata(host, mode, url="/", data=b"", uagent="GMixer-py", proxy=None, proxy_o
sock = tsocket(socket.AF_INET6, socket.SOCK_STREAM)
else: # IPv4
sock = tsocket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(5)
sock.connect(host)
sock.settimeout(None)
raw = (mode+" "+url+" HTTP/1.1\r\nHost: "+host[0]+":"+str(host[1])+"\r\nUser-Agent: "+uagent+"\r\nAccept: */*\r\nContent-Length: "+str(len(data))+"\r\n\r\n").encode()+data
sock.sendall(raw)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment