obgm / libcoap

A CoAP (RFC 7252) implementation in C
Other
786 stars 422 forks source link

How does a CoAP client detect an unsuccessful Put or Get #1110

Closed mikefoxTB closed 1 month ago

mikefoxTB commented 1 year ago

What is a good way for a client to detect a failed confirmed request (get or put) as soon as possible? One way is to wait for a response, but this might take two confirmed timeouts or about 3 minutes, however there are a lot of cases where a failed request could be detected sooner, ICMP port closed, non 2xx errors etc. How can a client quickly determine a request did not complete?

mrdeep1 commented 1 year ago

You can track this sort of information using an eventor nackhandler - see coap_handler(3). Relying on ICMP (COAP_NACK_ICMP_ISSUE) is unsafe as it may be filtered out by a firewall. Non 2xx responses can get picked up in theresponsehandler. Otherwise, as networks can be 'lossy', it is not safe to assume that 1 missed response means that the server has gone down, but counting COAP_EVENT_MSG_RETRANSMITTEDmay help you here.

mrdeep1 commented 1 month ago

@mikefoxTB Closing this issue as information provided. It can be re-opened if there are still questions about this.