Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tokens missing in response #25

Open
Extropy opened this issue May 12, 2021 · 4 comments
Open

tokens missing in response #25

Extropy opened this issue May 12, 2021 · 4 comments

Comments

@Extropy
Copy link

Extropy commented May 12, 2021

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.

@hirotakaster
Copy link
Owner

Hi @Extropy ,
Thank you for your report. I will test on my ESP32 with aiocoap like you.

@thankthemaker
Copy link

thankthemaker commented Aug 28, 2021

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.

@scottzach1
Copy link

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 😅).

@hirotakaster
Copy link
Owner

hirotakaster commented Aug 29, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants