Tanganelli / CoAPthon

CoAPthon is a python library to the CoAP protocol aligned with the RFC
MIT License
221 stars 130 forks source link

Sending CoAP message using http server post #158

Open pawelevans opened 4 years ago

pawelevans commented 4 years ago

Hi, I am using python-connect as http server on a beaglebone, and on pressing a web page button is handled by the httprequesthandler post. This executes the following: if self.path == 'discovery': client = HelperClient(server=("192.168.1.33", 5683)) response = client.get("/.well-known/core") if response is not None: print(response.pretty_print()) client.stop() return MyHTTPReqHandler

On pressing the button on the web page, the coap message is seen by the coap server on the IP address 192.168.1.33 and an ACK is returned.

This is what is shown at the client end on receipt of this ACK: 28.01.20 08:53:40 (+0000) python-connect 2020-01-28 08:53:40,043 - MainThread - coapthon.layers.messagelayer - DEBUG - send_request - From None, To ('192.168.1.33', 5683), None-None, GET-Sp, [Uri-Path: .well-known, Uri-Path: core, ] No payload 28.01.20 08:53:40 (+0000) python-connect 2020-01-28 08:53:40,053 - MainThread - coapthon.client.coap - DEBUG - send_datagram - From None, To ('192.168.1.33', 5683), CON-4902, GET-Sp, [Uri-Path: .well-known, Uri-Path: core, ] No payload 28.01.20 08:53:40 (+0000) python-connect 2020-01-28 08:53:40,072 - Thread-1 - coapthon.client.coap - DEBUG - Start receiver Thread 28.01.20 08:53:40 (+0000) python-connect 2020-01-28 08:53:40,086 - Thread-1 - coapthon.layers.messagelayer - DEBUG - receive_empty - From ('192.168.1.33', 5683), To None, ACK-4902, EMPTY-None, [] No payload 28.01.20 08:53:40 (+0000) python-connect 2020-01-28 08:53:40,098 - MainThread-Retry-4902 - coapthon.client.coap - DEBUG - retransmit loop ... enter 28.01.20 08:53:40 (+0000) python-connect 2020-01-28 08:53:40,114 - MainThread-Retry-4902 - coapthon.client.coap - DEBUG - retransmit loop ... exit

The web page is no longer being serviced and have to restart the web service to recover. Any help with this would be appreciated.

pawelevans commented 4 years ago

I note that the receiver thread did not exit, which may be the reason. Could this therefore be the receive handler is not happy with the empty payload in the response?