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

Issue found in multi-threaded environment, when multiple request and responses are processed in parallel #18

Open
usmaanirfan opened this issue Jul 29, 2020 · 3 comments

Comments

@usmaanirfan
Copy link

Hi,

We are using this library in our app and it works great! However, we are facing following issues while using the library in a multi-threaded environment, when multiple request and responses are sent in parallel:

Block 2 request is sent based on last request which is sent from library. It should be sent on the basis of latest block response received. When library receives any new block, it is creating a new request for getting its next block. This next block request should be created on the basis of block 1 which is just received. Instead, it is creating next block request on the basis of an old request (pendingCoAPMessageInTransmission) which is sent from library. This old request could be of any other request rather from the block received.

isMessageInTransmission variable is a shared variable in library. This is limitation in which if there are multiple request response done in parallel, we will not get correct state of isMessageInTransmission. If there are 2 message sent in parallel, we are not getting correct in transmission state.

Individual Blocks are received in application from the library. And app needs to append all blocks and create complete response. Instead, Library should handle all blocks and share complete response with app once all blocks are received.

Retransmitted response is not handled by the library. Application needs to check whether response is retransmitted or new one and then use the response based on the message ID. Library should discard response if app has already processed it or if it has already sent the same response to the app.

These are not fixed in the new Swift Library also.

Thanks!

@stuffrabbit
Copy link
Owner

Hi there!
Wow, thanks for all the feedback. I am glad that this library is actively used. Unfortunately, I don't have the bandwidth to follow up on all the issues you have mentioned and I am no longer active in following all updates around IETF, specifically, CoAP.

I would however strongly encourage you to create a pull request for this library, so that also other users could benefit from your suggested fixes.

I am happy to review your changes.

Wojtek

@usmaanirfan
Copy link
Author

Hi,

Thanks for the reply!

Is there any way that I can send/receive multiple COAP messages(concurrency) at a time using this library?

Thanks and Regards,
Usman

@illabo
Copy link

illabo commented Sep 8, 2021

@usmaanirfan Hey there! Have you resolved this issue? As I understand your description correctly you're sending multiple messages with a single SCClient instance. As a quite workable workaround I'd advice to create a client per thread instead. You still can reuse single transport layer object in all the clients to reduce the number of connections.

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

3 participants