CoAP-simple-library
CoAP-simple-library copied to clipboard
tokens missing in response
I ran into an issue using this library running on an ESP32, talking to a host application in Python using aiocoap. I am just starting with COAP, so I might be missing something, but I was able to fix it as follows:
Problem: aiocoap would keep sending a message and a reset because it could not associate the response from the ESP32 with a message it had sent. For my application, including the (packet.tokens, packet.tokenlen) in the call to sendResponse fixed the issue, but when the Python script requested an endpoint that I did not have on the ESP32 side, the problem persisted.
Suspected cause: aiocoap using tokens in a way not compatible with CoAP-simple
Work around/fix: I changed line 287/288 of coap-simple.cpp to read:
sendResponse(_udp->remoteIP(), _udp->remotePort(), packet.messageid, NULL, 0,COAP_NOT_FOUNT, COAP_NONE, packet.token, packet.tokenlen);
This way, when an unknown URI is requested, the response just also includes any tokens sent.
This fixed the problem. This did not happen when using Linux coap-client.
Hi @Extropy , Thank you for your report. I will test on my ESP32 with aiocoap like you.
Any update on this issue? I ran into the same problem. MacOS, Python3, aiocoap as client and ESP32 as server
Also Node.js with node-coap keeps retrying to send.
Apologies, I don't bring any solution to the (potentially) core problem.
I also found aiocoap to be problematic when developing on an ESP32 as a coap server. I ended up having better luck interfacing with the server using the trusty libcoap client (coap-client
command).
It isn't perfect as I no longer have access to this hardware, but a nice starting point for python might be scottzach1/CoapTesting (apologies yes self-promotion 😅).
Hi guys,
I check the aiocoap(0.4.1, on Mac python3), simple coap lib(1.3.22: latest) on ESP32 with aiocoap sample time server works well. so I don't find problem...
Anyway, if guys have something problem, please reports with your source code. Thank you.