go-coap icon indicating copy to clipboard operation
go-coap copied to clipboard

Server sends replies to all received retransmissions at the same time

Open mladedav opened this issue 3 years ago • 2 comments

I tried using the simple server with long-running operation and since the server doesn't send back ACKs, 3 retransmissions occured. After the handler finished, the server sent 4 answers, 1 for each received message, all four in less than 1 millisecond.

All messages were identical including message ID and token since they are presumably all responses to the same request.

mladedav avatar Mar 23 '21 23:03 mladedav

I believe that the issue lies here:

https://github.com/plgd-dev/go-coap/blob/4d466801917705aec7cd97b6b53c7502d4c1f7c5/udp/client/clientconn.go#L597

If the lock cannot be acquired right away, it means something is already processing the message and therefore the request is a retransmission/duplicate. Thus it can and should be dropped. Since the answer is not ready yet and will be sent as soon as it is available.

For the record if the server handles the request fast enough it currently works correctly (i.e. handler is not called again and the response is retransmitted) and with this change that would still be the case.

Am I missing something?

This is happening because the request was not confirmed by the server, but a scenario where the confirming message is lost is very real and in that case the same issue with retransmissions would occur and the server should be ready for that case.

mladedav avatar Mar 24 '21 15:03 mladedav

@mladedav Thx for find the core of problem.

jkralik avatar May 20 '21 19:05 jkralik