christgau / wsdd

A Web Service Discovery host daemon.
MIT License
808 stars 97 forks source link

Invalid URL and Timeout errors #149

Closed aljaxus closed 1 year ago

aljaxus commented 1 year ago

I'm using WSDD on my nas box (running alpine linux). So far I've tested the 0.7.0 and the latest master scripts.

Both error out with the same stacktraces.

The 192.168.1.99 address is an HP printer.

Same issues also present on ArchLinux install of WSDD.


The issue occurs as soon as I hit refresh in File explorer>Network on a Win10 box. I assume because Win10 broadcasts a "whois on the network", the printer answers, wsdd receives that response packet, fails to handle it and errors out. These are just assumptions. I have not verified any of it.


nas1:~# wsdd -w WORKGROUP -D
2022-08-15 17:28:43,716:wsdd WARNING(pid 19475): no interface given, using all interfaces
2022-08-15 17:28:46,746:asyncio ERROR(pid 19475): Exception in callback MulticastHandler.read_socket(<socket.socke... 55067, 0, 0)>)
handle: <Handle MulticastHandler.read_socket(<socket.socke... 55067, 0, 0)>)>
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/bin/wsdd", line 328, in read_socket
    handler.handle_packet(msg.decode('utf-8'), address)
  File "/usr/bin/wsdd", line 739, in handle_packet
    self.handle_message(msg, src)
  File "/usr/bin/wsdd", line 532, in handle_message
    retval = handler(header, body)
  File "/usr/bin/wsdd", line 814, in handle_resolve_match
    self.perform_metadata_exchange(endpoint, xaddr)
  File "/usr/bin/wsdd", line 846, in perform_metadata_exchange
    with urllib.request.urlopen(request, None, 2.0) as stream:
  File "/usr/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/usr/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 1377, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.10/urllib/request.py", line 1352, in do_open
    r = h.getresponse()
  File "/usr/lib/python3.10/http/client.py", line 1374, in getresponse
    response.begin()
  File "/usr/lib/python3.10/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.10/http/client.py", line 279, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.10/socket.py", line 705, in readinto
    return self._sock.recv_into(b)
TimeoutError: timed out
2022-08-15 17:28:46,755:asyncio ERROR(pid 19475): Exception in callback MulticastHandler.read_socket(<socket.socke... 55067, 0, 0)>)
handle: <Handle MulticastHandler.read_socket(<socket.socke... 55067, 0, 0)>)>
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/bin/wsdd", line 328, in read_socket
    handler.handle_packet(msg.decode('utf-8'), address)
  File "/usr/bin/wsdd", line 739, in handle_packet
    self.handle_message(msg, src)
  File "/usr/bin/wsdd", line 532, in handle_message
    retval = handler(header, body)
  File "/usr/bin/wsdd", line 795, in handle_probe_match
    self.perform_metadata_exchange(endpoint, xaddr)
  File "/usr/bin/wsdd", line 846, in perform_metadata_exchange
    with urllib.request.urlopen(request, None, 2.0) as stream:
  File "/usr/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/usr/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 1377, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1293, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/lib/python3.10/http/client.py", line 1127, in putrequest
    self._validate_path(url)
  File "/usr/lib/python3.10/http/client.py", line 1227, in _validate_path
    raise InvalidURL(f"URL can't contain control characters. {url!r} "
http.client.InvalidURL: URL can't contain control characters. '/ http://[2A00:EE2:670B:2300:D2BF:9CFF:FEA6:3F51%bond0]:3911/ http://192.168.1.99:3911/' (found at least ' ')
----------------------------------------
Exception occurred during processing of request from ('fe80::21c:c4ff:fe82:f684', 41602, 0, 4)
Traceback (most recent call last):
  File "/usr/lib/python3.10/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.10/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.10/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.10/socketserver.py", line 747, in __init__
    self.handle()
  File "/usr/lib/python3.10/http/server.py", line 425, in handle
    self.handle_one_request()
  File "/usr/lib/python3.10/http/server.py", line 413, in handle_one_request
    method()
  File "/usr/bin/wsdd", line 1094, in do_POST
    self.wfile.write(response.encode('utf-8'))
  File "/usr/lib/python3.10/socketserver.py", line 826, in write
    self._sock.sendall(b)
BrokenPipeError: [Errno 32] Broken pipe
----------------------------------------
2022-08-15 17:28:46,762:asyncio ERROR(pid 19475): Exception in callback MulticastHandler.read_socket(<socket.socke....0.0', 34647)>)
handle: <Handle MulticastHandler.read_socket(<socket.socke....0.0', 34647)>)>
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/bin/wsdd", line 328, in read_socket
    handler.handle_packet(msg.decode('utf-8'), address)
  File "/usr/bin/wsdd", line 739, in handle_packet
    self.handle_message(msg, src)
  File "/usr/bin/wsdd", line 532, in handle_message
    retval = handler(header, body)
  File "/usr/bin/wsdd", line 795, in handle_probe_match
    self.perform_metadata_exchange(endpoint, xaddr)
  File "/usr/bin/wsdd", line 846, in perform_metadata_exchange
    with urllib.request.urlopen(request, None, 2.0) as stream:
  File "/usr/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/usr/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 1377, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1293, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/lib/python3.10/http/client.py", line 1127, in putrequest
    self._validate_path(url)
  File "/usr/lib/python3.10/http/client.py", line 1227, in _validate_path
    raise InvalidURL(f"URL can't contain control characters. {url!r} "
http.client.InvalidURL: URL can't contain control characters. '/ http://[FE80::D2BF:9CFF:FEA6:3F51]:3911/ http://[2A00:EE2:670B:2300:D2BF:9CFF:FEA6:3F51]:3911/' (found at least ' ')

Sorry for the wall of text. Github sadly doesn't support spoilers.