mwasilak / txThings

CoAP library for Twisted
94 stars 43 forks source link

Unhandled Error #26

Open engrjislam opened 4 years ago

engrjislam commented 4 years ago
2020-01-21 20:47:43+0200 [Coap (UDP)] Unhandled Error
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/site-packages/twisted/python/log.py", line 86, in callWithContext
        return context.call({ILogContext: newCtx}, func, *args, **kw)
      File "/usr/local/lib/python2.7/site-packages/twisted/python/context.py", line 122, in callWithContext
        return self.currentContext().callWithContext(ctx, func, *args, **kw)
      File "/usr/local/lib/python2.7/site-packages/twisted/python/context.py", line 85, in callWithContext
        return func(*args,**kw)
      File "/usr/local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
        why = selectable.doRead()
    --- <exception caught here> ---
      File "/usr/local/lib/python2.7/site-packages/twisted/internet/udp.py", line 249, in doRead
        self.protocol.datagramReceived(data, addr)
      File "/usr/local/lib/python2.7/site-packages/txthings/coap.py", line 790, in datagramReceived
        message = Message.decode(data, (ip_address(host), port), self)
      File "/usr/local/lib/python2.7/site-packages/ipaddress.py", line 165, in ip_address
        ' a unicode object?' % address)
    ipaddress.AddressValueError: '127.0.0.1' does not appear to be an IPv4 or IPv6 address. Did you pass in a bytes (str in Python 2) instead of a unicode object?

host into the following line needs to be converted into unicode:

File "/usr/local/lib/python2.7/site-packages/txthings/coap.py", line 790, in datagramReceived
        message = Message.decode(data, (ip_address(host), port), self)

For example: message = Message.decode(data, (ip_address(unicode(host)), port), self)