coapjs / node-coap

CoAP - Node.js style
MIT License
531 stars 154 forks source link

Client observe does not work for large message #325

Closed desireesantos closed 2 years ago

desireesantos commented 2 years ago

On the client side, I want to observe a resource with a large message and I'm getting a bad request as a status code. I would like to intensify that for small and medium messages(size until 1K), it works well.

... const setup = { host: 'CLOUD_IP', observe: true, port: 5683, pathname: '/middlewareToCloud', method: 'GET' } const req = coap.request(setup)

I had added the option Block2, but it did not work: req.setOption('Block2', Buffer.of(0x2))

What do I need to do to get the payload for the large message? Am I doing something wrong or is it an issue for a large message?

JKRhb commented 2 years ago

Hi! Thanks for reporting the issue :) Could you try out a bigger block size? You can increase argument in the buffer up to 0x06 (for the maximum blocksize of 1024 bytes), maybe this could help?

desireesantos commented 2 years ago

I changed the block2 toreq.setOption('Block2', Buffer.of(0x6))

Screenshot 2021-12-03 at 10 40 17
JKRhb commented 2 years ago

Hmm, that is strange :/ I found no indication in the specification both for blockwise and observe that could hint why this is interpreted as a bad request. Does sending the observe request without the block2 option set also lead to an error?

Perhaps it could also be an issue with the server implementation? Is the server also using node-coap or another library?

desireesantos commented 2 years ago

Good point @JKRhb! From server-side is another library(libcoap). I'll will change from libcoap to node-coap to check!

Currently, I use the Copper plugin to execute some tests and I can get large messages using this plugin.

Screenshot 2021-12-03 at 11 30 14
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions.

stale[bot] commented 2 years ago

This issue has been automatically closed because of inactivity. Please open a new issue if still relevant and make sure to include all relevant details, logs and reproduction steps. Thank you for your contributions.