Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Exception in discover() #17

Open
tnjohnston opened this issue Feb 3, 2022 · 3 comments
Open

Uncaught Exception in discover() #17

tnjohnston opened this issue Feb 3, 2022 · 3 comments

Comments

@tnjohnston
Copy link

I was unable to use this library on my network due to the following uncaught exception when calling the discover() method.

Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import upnpy
upnp = upnpy.UPnP()
devices = upnp.discover()

Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/upnpy/upnp/UPnP.py", line 33, in discover
for device in self.ssdp.m_search(discover_delay=delay, st='upnp:rootdevice', **headers):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/upnpy/ssdp/SSDPRequest.py", line 50, in m_search
devices = self._send_request(self._get_raw_request())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/upnpy/ssdp/SSDPRequest.py", line 100, in _send_request
device = SSDPDevice(addr, response.decode())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/upnpy/ssdp/SSDPDevice.py", line 83, in init
self._get_description_request(utils.parse_http_header(response, 'Location'))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/upnpy/ssdp/SSDPDevice.py", line 117, in _get_description_request
device_description = utils.make_http_request(url).read()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/upnpy/utils.py", line 81, in make_http_request
return urllib.request.urlopen(request)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 519, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 496, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1377, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1352, in do_open
r = h.getresponse()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1374, in getresponse
response.begin()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 318, in begin
version, status, reason = self._read_status()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 279, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/socket.py", line 705, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer

@coofercat
Copy link

With a very simple program:

#!/usr/bin/python3

import upnpy

upnp = upnpy.UPnP()
devices = upnp.discover()

I too get an exception:

Traceback (most recent call last):
  File "/home/pi/backend/./upnp_debug.py", line 6, in <module>
    devices = upnp.discover()
  File "/home/pi/.local/lib/python3.9/site-packages/upnpy/upnp/UPnP.py", line 33, in discover
    for device in self.ssdp.m_search(discover_delay=delay, st='upnp:rootdevice', **headers):
  File "/home/pi/.local/lib/python3.9/site-packages/upnpy/ssdp/SSDPRequest.py", line 50, in m_search
    devices = self._send_request(self._get_raw_request())
  File "/home/pi/.local/lib/python3.9/site-packages/upnpy/ssdp/SSDPRequest.py", line 100, in _send_request
    device = SSDPDevice(addr, response.decode())
  File "/home/pi/.local/lib/python3.9/site-packages/upnpy/ssdp/SSDPDevice.py", line 87, in __init__
    self._get_services_request()
  File "/home/pi/.local/lib/python3.9/site-packages/upnpy/ssdp/SSDPDevice.py", line 23, in wrapper
    return func(device, *args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/upnpy/ssdp/SSDPDevice.py", line 54, in wrapper
    return func(instance, *args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/upnpy/ssdp/SSDPDevice.py", line 171, in _get_services_request
    event_sub_url = service.getElementsByTagName('eventSubURL')[0].firstChild.nodeValue
AttributeError: 'NoneType' object has no attribute 'nodeValue'

(not the same, but much easier to read)

@mark-pippin
Copy link

test.py is the 2nd example on the home page:

import test
Traceback (most recent call last):
File "", line 1, in
File "C:\python\2dshooter\network\test.py", line 7, in
devices = upnp.discover()
File "C:\Projects\Kraken\venv\lib\site-packages\upnpy\upnp\UPnP.py", line 33, in discover
for device in self.ssdp.m_search(discover_delay=delay, st='upnp:rootdevice', **headers):
File "C:\Projects\Kraken\venv\lib\site-packages\upnpy\ssdp\SSDPRequest.py", line 50, in m_search
devices = self._send_request(self._get_raw_request())
File "C:\Projects\Kraken\venv\lib\site-packages\upnpy\ssdp\SSDPRequest.py", line 100, in _send_request
device = SSDPDevice(addr, response.decode())
File "C:\Projects\Kraken\venv\lib\site-packages\upnpy\ssdp\SSDPDevice.py", line 87, in init
self._get_services_request()
File "C:\Projects\Kraken\venv\lib\site-packages\upnpy\ssdp\SSDPDevice.py", line 23, in wrapper
return func(device, *args, **kwargs)
File "C:\Projects\Kraken\venv\lib\site-packages\upnpy\ssdp\SSDPDevice.py", line 54, in wrapper
return func(instance, *args, **kwargs)
File "C:\Projects\Kraken\venv\lib\site-packages\upnpy\ssdp\SSDPDevice.py", line 170, in _get_services_request
control_url = service.getElementsByTagName('controlURL')[0].firstChild.nodeValue
AttributeError: 'NoneType' object has no attribute 'nodeValue'

mark-pippin added a commit to mark-pippin/upnpy-bugfix that referenced this issue May 15, 2022
@mark-pippin
Copy link

Fix in PR:
#19

for others, if that PR has not been merged, you may see here if you wish:
https://github.com/Velas2/upnpy-bugfix/tree/frozen-bug-fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants