Git Product home page Git Product logo

coapthon3's Introduction

Build Status

CoAPthon3

CoAPthon3 is a porting to python3 of my CoAPthon library. CoAPthon3 is a python3 library to the CoAP protocol compliant with the RFC. Branch is available for the Twisted framework.

coapthon3's People

Contributors

bobzomer avatar fabaff avatar galewombat avatar hahahannes avatar hubertmis avatar matth314 avatar mcfreis avatar michieldwitte avatar tanganelli avatar urbas avatar warner83 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coapthon3's Issues

tag release 1.0.2 and push to pip to fix isAlive() for Python 3.9 Users

Ubuntu 21.04 and likely other distros now use Python-3.9.

It removed the long-deprecated isAlive() which was fixed in git this March.

Please make this and the other fixes in git available on pip by tagging release 1.0.2
and pushing it to pip like you did in 2018 for version 1.0.1.

Thanks a ton ;-)

Block=(0,0,16) is not support

When block param is (0, 0, 16), like the following code,
response = client.get(path, block2=(0, 0, 16))
The error log is:
Traceback (most recent call last):
File "coapsrv.py", line 23, in
main()
File "coapsrv.py", line 16, in main
server.listen(10)
File "/usr/local/lib64/python3.6/site-packages/coapthon/server/coap.py", line 153, in listen
logger.info("receive_datagram - " + str(message))
File "/usr/local/lib64/python3.6/site-packages/coapthon/messages/message.py", line 734, in str
return self.line_print
File "/usr/local/lib64/python3.6/site-packages/coapthon/messages/message.py", line 719, in line_print
msg += "{name}: {value}, ".format(name=opt.name, value=utils.parse_blockwise(opt.value))
File "/usr/local/lib64/python3.6/site-packages/coapthon/utils.py", line 94, in parse_blockwise
num = value & 0xFFFFF0
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'

Coapthon log handling is not friendly to integration

Coapthons way of using the Python logging module isn't great if you're integrating it into a larger package.

Importing any of the coapthon modules seems to override any logger settings, and not only for, say, logger coapthon.client.coap but also for the root logger and more.

In addition, a file "logging.conf" is always created in the current directory.

All of this wreaks havoc with my carefully setup logging structure, and there is no way I can event monkeypatch it (by overriding coapthon.utils.create_logging()) because the references to the logging.conf file are all over the place.

Specific implementation question on multiple coap responses

@Tanganelli Sorry for the question but perhaps you can have a quick look on an usage of your library. I'm having a problem regarding a philips air purifier, which uses a propriatary connection, realized with coap.

Issue:

In short:

  • send a request to device
  • device responds with a coap-message (which is AES encrypted json)
  • decrypt the AES

The problem:

  • some devices seem to have payload bigger than 1138 bytes (which seems to be the limit), it is cut of and can't be decoded therefore
  • My guess is that I should get 2 coap-responses on one request
  • I've little knowledge about coap, I've reused this part of code, which seems only to work were the payload fits into one coap-package
  • And I own a device where the payload fits into one coap package (so not really easy to test/fix)
  • Relevant code is here: https://github.com/Cyber1000/py-air-control/blob/0e530158d283da5bb0c306137ea1681a4ce10b7b/pyairctrl/airctrl.py#L792
    • mk_request followed by send_request
    • the client is a HelperClient: from coapthon.client.helperclient import HelperClient

Is there something I'm missing to get multiple responses on one request or to get a bigger response? Or do you think, that there must be something devicespecific which doesn't sound like coap ...

Thanks for your time!

"Un-Matched incoming response message" for /obs and Exception for /.well-known/core

Hi,

I have a very simple script to query californium.eclipse.org. Im querying two URIs

  1. /obs - This gives the Un-Matched incoming message log and keeps on retrying
  2. /.well-known/core - This throws an exception.

Is there anything Im doing wrong? I have tried with a different library (in ruby) and it works so it doesnt look like it is a server or connection issue.

Below are the details:


  1. script:

#!/usr/bin/python3
from coapthon.client.helperclient import HelperClient

c = HelperClient(server=("californium.eclipse.org", 5683))
r = c.get("/.well-known/core") # The other query is for /obs
print("r class {}".format(r.class.name))


  1. Exception for /.well-known/core

Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/coapthon/serializer.py", line 76, in deserialize
option_item = defines.OptionRegistry.LIST[current_option]
KeyError: 28

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.5/dist-packages/coapthon/client/coap.py", line 261, in receive_datagram
message = serializer.deserialize(datagram, source)
File "/usr/local/lib/python3.5/dist-packages/coapthon/serializer.py", line 78, in deserialize
(opt_critical, _, _) = defines.OptionRegistry.get_option_flags(current_option)
File "/usr/local/lib/python3.5/dist-packages/coapthon/defines.py", line 166, in get_option_flags
opt_bytes = array.array('B', '\0\0')
TypeError: cannot use a str to initialize an array with typecode 'B'

Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/coapthon/serializer.py", line 76, in deserialize
option_item = defines.OptionRegistry.LIST[current_option]
KeyError: 28

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.5/dist-packages/coapthon/client/coap.py", line 261, in receive_datagram
message = serializer.deserialize(datagram, source)
File "/usr/local/lib/python3.5/dist-packages/coapthon/serializer.py", line 78, in deserialize
(opt_critical, _, _) = defines.OptionRegistry.get_option_flags(current_option)
File "/usr/local/lib/python3.5/dist-packages/coapthon/defines.py", line 166, in get_option_flags
opt_bytes = array.array('B', '\0\0')
TypeError: cannot use a str to initialize an array with typecode 'B'

Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/coapthon/serializer.py", line 76, in deserialize
option_item = defines.OptionRegistry.LIST[current_option]
KeyError: 28

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.5/dist-packages/coapthon/client/coap.py", line 261, in receive_datagram
message = serializer.deserialize(datagram, source)
File "/usr/local/lib/python3.5/dist-packages/coapthon/serializer.py", line 78, in deserialize
(opt_critical, _, _) = defines.OptionRegistry.get_option_flags(current_option)
File "/usr/local/lib/python3.5/dist-packages/coapthon/defines.py", line 166, in get_option_flags
opt_bytes = array.array('B', '\0\0')
TypeError: cannot use a str to initialize an array with typecode 'B'

Exception in thread Thread-4:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/coapthon/serializer.py", line 76, in deserialize
option_item = defines.OptionRegistry.LIST[current_option]
KeyError: 28

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.5/dist-packages/coapthon/client/coap.py", line 261, in receive_datagram
message = serializer.deserialize(datagram, source)
File "/usr/local/lib/python3.5/dist-packages/coapthon/serializer.py", line 78, in deserialize
(opt_critical, _, _) = defines.OptionRegistry.get_option_flags(current_option)
File "/usr/local/lib/python3.5/dist-packages/coapthon/defines.py", line 166, in get_option_flags
opt_bytes = array.array('B', '\0\0')
TypeError: cannot use a str to initialize an array with typecode 'B'


  1. Log messages for /.well-known/core

2018-04-10 16:21:35,431 - MainThread - coapthon.layers.messagelayer - DEBUG - send_request - From None, To ('californium.eclipse.org', 5683), None-None, GET-ez, [Uri-Path: .well-known, Uri-Path: core, ] No payload
2018-04-10 16:21:35,431 - MainThread - coapthon.client.coap - DEBUG - send_datagram - From None, To ('californium.eclipse.org', 5683), CON-34208, GET-ez, [Uri-Path: .well-known, Uri-Path: core, ] No payload
2018-04-10 16:21:35,444 - Thread-1 - coapthon.client.coap - DEBUG - Start receiver Thread
2018-04-10 16:21:35,444 - MainThread-Retry-34208 - coapthon.client.coap - DEBUG - retransmit loop ... enter
2018-04-10 16:21:38,252 - MainThread-Retry-34208 - coapthon.client.coap - DEBUG - retransmit loop ... retransmit Request
2018-04-10 16:21:38,252 - MainThread-Retry-34208 - coapthon.client.coap - DEBUG - send_datagram - From None, To ('californium.eclipse.org', 5683), CON-34208, GET-ez, [Uri-Path: .well-known, Uri-Path: core, ] No payload
2018-04-10 16:21:38,263 - Thread-2 - coapthon.client.coap - DEBUG - Start receiver Thread
2018-04-10 16:21:43,876 - MainThread-Retry-34208 - coapthon.client.coap - DEBUG - retransmit loop ... retransmit Request
2018-04-10 16:21:43,876 - MainThread-Retry-34208 - coapthon.client.coap - DEBUG - send_datagram - From None, To ('californium.eclipse.org', 5683), CON-34208, GET-ez, [Uri-Path: .well-known, Uri-Path: core, ] No payload
2018-04-10 16:21:43,887 - Thread-3 - coapthon.client.coap - DEBUG - Start receiver Thread
2018-04-10 16:21:55,113 - MainThread-Retry-34208 - coapthon.client.coap - DEBUG - retransmit loop ... retransmit Request
2018-04-10 16:21:55,114 - MainThread-Retry-34208 - coapthon.client.coap - DEBUG - send_datagram - From None, To ('californium.eclipse.org', 5683), CON-34208, GET-ez, [Uri-Path: .well-known, Uri-Path: core, ] No payload
2018-04-10 16:21:55,138 - Thread-4 - coapthon.client.coap - DEBUG - Start receiver Thread
2018-04-10 16:23:02,496 - MainThread-Retry-34208 - coapthon.client.coap - WARNING - Give up on message From None, To ('californium.eclipse.org', 5683), CON-34208, GET-ez, [Uri-Path: .well-known, Uri-Path: core, ] No payload
2018-04-10 16:23:02,497 - MainThread-Retry-34208 - coapthon.client.coap - DEBUG - retransmit loop ... exit
r class NoneType


  1. Log messages for /obs

2018-04-10 16:18:25,261 - MainThread - coapthon.layers.messagelayer - DEBUG - send_request - From None, To ('californium.eclipse.org', 5683), None-None, GET-Fa, [Uri-Path: obs, ] No payload
2018-04-10 16:18:25,261 - MainThread - coapthon.client.coap - DEBUG - send_datagram - From None, To ('californium.eclipse.org', 5683), CON-39116, GET-Fa, [Uri-Path: obs, ] No payload
2018-04-10 16:18:25,271 - Thread-1 - coapthon.client.coap - DEBUG - Start receiver Thread
2018-04-10 16:18:25,271 - MainThread-Retry-39116 - coapthon.client.coap - DEBUG - retransmit loop ... enter
2018-04-10 16:18:25,681 - Thread-1 - coapthon.client.coap - DEBUG - receive_datagram - From ('104.196.15.150', 5683), To None, ACK-39116, CONTENT-Fa, [Content-Type: 0, Max-Age: 5, ] 10:48:21...8 bytes
2018-04-10 16:18:25,681 - Thread-1 - coapthon.layers.messagelayer - DEBUG - receive_response - From ('104.196.15.150', 5683), To None, ACK-39116, CONTENT-Fa, [Content-Type: 0, Max-Age: 5, ] 10:48:21...8 bytes
2018-04-10 16:18:25,681 - Thread-1 - coapthon.layers.messagelayer - WARNING - Un-Matched incoming response message 104.196.15.150:5683
2018-04-10 16:18:27,531 - MainThread-Retry-39116 - coapthon.client.coap - DEBUG - retransmit loop ... retransmit Request
2018-04-10 16:18:27,531 - MainThread-Retry-39116 - coapthon.client.coap - DEBUG - send_datagram - From None, To ('californium.eclipse.org', 5683), CON-39116, GET-Fa, [Uri-Path: obs, ] No payload
2018-04-10 16:18:27,932 - Thread-1 - coapthon.client.coap - DEBUG - receive_datagram - From ('104.196.15.150', 5683), To None, ACK-39116, CONTENT-Fa, [Content-Type: 0, Max-Age: 5, ] 10:48:21...8 bytes
2018-04-10 16:18:27,932 - Thread-1 - coapthon.layers.messagelayer - DEBUG - receive_response - From ('104.196.15.150', 5683), To None, ACK-39116, CONTENT-Fa, [Content-Type: 0, Max-Age: 5, ] 10:48:21...8 bytes
2018-04-10 16:18:27,932 - Thread-1 - coapthon.layers.messagelayer - WARNING - Un-Matched incoming response message 104.196.15.150:5683
2018-04-10 16:18:32,061 - MainThread-Retry-39116 - coapthon.client.coap - DEBUG - retransmit loop ... retransmit Request
2018-04-10 16:18:32,062 - MainThread-Retry-39116 - coapthon.client.coap - DEBUG - send_datagram - From None, To ('californium.eclipse.org', 5683), CON-39116, GET-Fa, [Uri-Path: obs, ] No payload
2018-04-10 16:18:32,375 - Thread-1 - coapthon.client.coap - DEBUG - receive_datagram - From ('104.196.15.150', 5683), To None, ACK-39116, CONTENT-Fa, [Content-Type: 0, Max-Age: 5, ] 10:48:21...8 bytes
2018-04-10 16:18:32,376 - Thread-1 - coapthon.layers.messagelayer - DEBUG - receive_response - From ('104.196.15.150', 5683), To None, ACK-39116, CONTENT-Fa, [Content-Type: 0, Max-Age: 5, ] 10:48:21...8 bytes
2018-04-10 16:18:32,376 - Thread-1 - coapthon.layers.messagelayer - WARNING - Un-Matched incoming response message 104.196.15.150:5683
2018-04-10 16:18:41,110 - MainThread-Retry-39116 - coapthon.client.coap - DEBUG - retransmit loop ... retransmit Request
2018-04-10 16:18:41,110 - MainThread-Retry-39116 - coapthon.client.coap - DEBUG - send_datagram - From None, To ('californium.eclipse.org', 5683), CON-39116, GET-Fa, [Uri-Path: obs, ] No payload
2018-04-10 16:18:41,963 - Thread-1 - coapthon.client.coap - DEBUG - receive_datagram - From ('104.196.15.150', 5683), To None, ACK-39116, CONTENT-Fa, [Content-Type: 0, Max-Age: 5, ] 10:48:21...8 bytes
2018-04-10 16:18:41,963 - Thread-1 - coapthon.layers.messagelayer - DEBUG - receive_response - From ('104.196.15.150', 5683), To None, ACK-39116, CONTENT-Fa, [Content-Type: 0, Max-Age: 5, ] 10:48:21...8 bytes
2018-04-10 16:18:41,963 - Thread-1 - coapthon.layers.messagelayer - WARNING - Un-Matched incoming response message 104.196.15.150:5683
2018-04-10 16:19:35,829 - MainThread-Retry-39116 - coapthon.client.coap - WARNING - Give up on message From None, To ('californium.eclipse.org', 5683), CON-39116, GET-Fa, [Uri-Path: obs, ] No payload
2018-04-10 16:19:35,830 - MainThread-Retry-39116 - coapthon.client.coap - DEBUG - retransmit loop ... exit
r class NoneType

Include doc files

Please include the README.md and the LICENSE file for the releases on PyPI. This is something that will come up during the review to include CoAPthon3 into the Fedora Package Collection.

If that's is done then please publish a new new release.

Thanks in advance.

'Request' object has no attribute 'payload_type'

In serializer.deserializer, we have the following check:
if message.payload_type == defines.Content_types["application/octet-stream"]:

but, the 'Request' object has no attribute named 'payload_type'

Problem with nested endpoints

I am encountering a problem with nested endpoints when the first part of the path is registered as an own resource, like in Case 2 below. I have a patch but have to prepare it for a PR if wished.

Case 1 (working):

from coapthon.server.coap import CoAP
from coapthon.resources.resource import Resource

class CoAPServer(CoAP):
    def __init__(self, host, port):
        CoAP.__init__(self, (host, port))
        self.add_resource('one/', OneResource())
        self.add_resource('one/two/', TwoResource())

class OneResource(Resource):
    def __init__(self, name="OneResource", coap_server=None):
        super(OneResource, self).__init__(name, coap_server, visible=True,
                                            observable=True, allow_children=True)

    def render_GET(self, request):
        print("level_1")
        self.payload = 'level_1'
        return self

class TwoResource(Resource):
    def __init__(self, name="TwoResource", coap_server=None):
        super(TwoResource, self).__init__(name, coap_server, visible=True,
                                            observable=True, allow_children=True)

    def render_GET(self, request):
        print("level_2")
        self.payload = 'level_2'
        return self

server = CoAPServer("0.0.0.0", 5683)
try:
    server.listen(10)
except KeyboardInterrupt:
    server.close()
from coapthon.client.helperclient import HelperClient
client = HelperClient(server=('127.0.0.1', 5683))
client.get('/one').pretty_print() # level_1
client.get('/one/two').pretty_print() # level_2

Case 2 (not working):

class CoAPServer(CoAP):
    def __init__(self, host, port):
        CoAP.__init__(self, (host, port))
        self.add_resource('one/', OneResource())
        self.add_resource('two/three/', TwoResource())

class OneResource(Resource):
    def __init__(self, name="OneResource", coap_server=None):
        super(OneResource, self).__init__(name, coap_server, visible=True,
                                            observable=True, allow_children=True)

    def render_GET(self, request):
        print("level_1")
        self.payload = 'level_1'
        return self

class TwoResource(Resource):
    def __init__(self, name="TwoResource", coap_server=None):
        super(TwoResource, self).__init__(name, coap_server, visible=True,
                                            observable=True, allow_children=True)

    def render_GET(self, request):
        print("level_2")
        self.payload = 'level_2'
        return self

server = CoAPServer("0.0.0.0", 5683)
try:
    server.listen(10)
except KeyboardInterrupt:
    server.close()
from coapthon.client.helperclient import HelperClient
client = HelperClient(server=('127.0.0.1', 5683))
client.get('/one').pretty_print() # level_1
client.get('/two/three').pretty_print() # not found

Response packet size can't be bigger than 1500

I used the coapthon as the client to send GET request, the server side sent a package a little bigger than 1500. then only partial data available in the response.payload.

Any suggestions on how to solve it is appreciated.

Denial of Service vulnerability caused by improper exception handling while parsing of CoAP messages

Multiple sample applications from CoAPthon3 library are vulnerable to Denial of Service attacks caused by maliciously crafted CoAP messages.
Method Serialize.deserialize() improperly handle multiple exception types leading to crash of applications (including standard CoAP server, CoAP client, example collect CoAP server and client).

Example payloads and unhandled exceptions:

  1. File: crash_000_UnicodeDecodeError.raw

Error message:
File "CoAPthon3-master/coapthon/serializer.py", line 57, in deserialize
message.token = token_value.decode("utf-8")
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xfd in position 2: invalid start byte

  1. File: crash_005_UnicodeDecodeError.raw

Error message:
File "CoAPthon3-master/coapthon/serializer.py", line 57, in deserialize
message.token = token_value.decode("utf-8")
File "CoAPthon3-master/coapthon/messages/message.py", line 126, in token
value = str(value)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0740' in position 1: ordinal not in range(128)

Proposed CVSS score:
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H (7.5 - High)

Mitigation:
All exception types should be handled in the main loop of CoAPthon3 applications (including standard CoAP server, CoAP client, example collect CoAP server and client), to provide uninterruptible service.

CoAPthon3_crashes.zip

Issue was reported via email on 26th of February to CoAPthon3 developers and registered in CVE database (reserved id is: CVE-2018-12679).

ipv6 support

Hi - it looks like some work is needed for ipv6 compatibility?
The ipv6 test is commented out and has some issues...? it runs and says OK so maybe its OK?
I have tested the coapclient against the server and a GET of /xml for example recives Un-Matched incoming response messages.
coap-client can GET from the same server OK.
Thanks!

client.cancel_observing doesn't appear to cancel callback

Hi, I am using coapthon3 with remi (a gui based python web server) whereby the user can generate coap messages from a browser.
Setting an observe is working fine, and when the user cancels this 'client.cancel_observing' is called on receipt of the next notification and issue's a RST to the remote. If the observation is cancelled, why is my callback function still being called for new notifications, albeit no more RST are sent out, just ACK's?

logging file auto created

There is no easy way to disable/control the default logging and/or creation of the logging.conf file.

NO_RESPONSE not supported in 1.0.1

When using CoAPthon3==1.0.1, deserializing messages with the NO_RESPONSE option set throws an error:

Traceback (most recent call last):
  File "main.py", line 12, in <module>
    coap_message = Serializer.deserialize(data, addr)
  File "/tmp/coapthon/serializer.py", line 78, in deserialize
    (opt_critical, _, _) = defines.OptionRegistry.get_option_flags(current_option)
  File "/tmp/coapthon/defines.py", line 166, in get_option_flags
    opt_bytes = array.array('B', '\0\0')
TypeError: cannot use a str to initialize an array with typecode 'B'

It appears that version was published before NO_RESPONSE was added to coapthon.defines.OptionRegistry. Installing from the master branch works fine, but I was just curious if there were any plans to push a new release in the near future?

On RST with empty response, transaction.response could be None

During RST command, if the transaction response is empty, the field transaction.response may still be None. However, it is referenced at line 174 in file coapthon/layers/messagelayer.py, function receive_empty():
elif not transaction.response.acknowledged:
Suggestion: first check if transaction.response is not None:
elif (transaction.response is not None) and (not transaction.response.acknowledged):
This is exactly what is done in the case of the ACK command, at line 169 of the same file.

CoAP Forward Proxy Issue

There seems to be a problem in coapthon/layers/forwardLayer.py on line 3, where coapclient import HelperClient needs to be changed to from coapthon.client.helperclient import HelperClient

AttributeError: 'function' object has no attribute 'setter'

Getting the following issue when running the latest commit

Traceback (most recent call last): File "main.py", line 22, in <module> from coapthon.server.coap import CoAP File "/home/pi/dev/captivate_server/dataViz/CoAPthon3/coapthon/server/coap.py", line 9, in <module> from coapthon.layers.blocklayer import BlockLayer File "/home/pi/dev/captivate_server/dataViz/CoAPthon3/coapthon/layers/blocklayer.py", line 5, in <module> from coapthon.messages.request import Request File "/home/pi/dev/captivate_server/dataViz/CoAPthon3/coapthon/messages/request.py", line 2, in <module> from coapthon.messages.message import Message File "/home/pi/dev/captivate_server/dataViz/CoAPthon3/coapthon/messages/message.py", line 12, in <module> class Message(object): File "/home/pi/dev/captivate_server/dataViz/CoAPthon3/coapthon/messages/message.py", line 656, in Message @size1.setter AttributeError: 'function' object has no attribute 'setter'

Python3.11 support

Hi,

I understand that this module is still working on python3.11, right? Did anyone test it?

Ty!

Truncated answers

We use CoAPthon3 to communicate with Philips air purifier (see https://github.com/rgerganov/py-air-control/). In some cases, with some models, the CoAP answer is truncated by the library.

We can see in coapthon/client/coap.py, line 239, method receive_datagram:

                datagram, addr = self._socket.recvfrom(1152)

I've cloned the CoAPthon3 library and modified this line to:

                datagram, addr = self._socket.recvfrom(1500)

And now it works properly.

I will make a PR. Would you think possible to accept it and update pip package accordingly?

Get binary response from server in Client

Hello Giacomo Tanganelli,

To receive binary data from the CoAP Server it can only be sent with content_type application/octet-stream other content types like application/cbor can be used within the server but are not recognized as binary from the client.

I think the following line has to be modified:
https://github.com/Tanganelli/CoAPthon3/blob/master/coapthon/serializer.py#L117

Currently the payload of the response from the server is only treated as as binary when the content type is set to application/octet-stream.
Maybe you could extend this to application/cbor

Best Regards
Martin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.