jtriley / pystun

A Python STUN client for getting NAT type and external IP
https://github.com/jtriley/pystun
MIT License
435 stars 154 forks source link

KeyError: u'0800' #33

Open ofergr opened 4 years ago

ofergr commented 4 years ago

From time to time I get the following exception:

Exception in thread StunReq: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 754, in run self.target(*self.args, **self.__kwargs) File "stuntask.py", line 24, in run send_stun_request() File "stuntask.py", line 94, in send_stun_request nat_type, ext_ip, ext_port = stun.get_ip_info(addr, 4789) File "/home/oferg/mycode/pystun3-1.0.0/stun/init.py", line 275, in get_ip_info stun_host=stun_host, stun_port=stun_port) File "/home/oferg/mycode/pystun3-1.0.0/stun/init__.py", line 215, in get_nat_type ret = stun_test(s, stunhost, port, source_ip, source_port) File "/home/oferg/mycode/pystun3-1.0.0/stun/init.py", line 150, in stun_test bind_resp_msg = dictValToMsgType[msgtype] == "BindResponseMsg" KeyError: u'0800'

What can be the cause of this? I can try and catch the exception, but I have no idea what to do with it :-)

Need to add that I have changed the list of STUN server to a more current one: STUN_SERVERS = ( 'stun.l.google.com:19302', 'stun1.l.google.com:19302', 'stun2.l.google.com:19302', 'stun3.l.google.com:19302', 'stun4.l.google.com:19302', 'stun.ekiga.net' )

Also add handling of STUN server addresses which has port in it, as in the above list (simple split(':'), nothing fancy).

Thanks!