Search code examples
coap

To support Keep-alive functionality of CoAP


I'm checking that CoAP can support keep-alive functionality like HTTP. Can CoAP support keep-alive functionality? If yes, how to set it up?


Solution

  • Currently, CoAP does not have a keepalive feature. One could build its own keepalive by using observation on a resource and sending a notification every x amount of time.

    Furthermore, the Http concept of Http keepalive is to keep a single TCP connection alive so that many request and response can be exchange instead of using multiple connections. CoAP is primarily used over UDP, so connections cannot be persisted so it would not really achieve the same goal.

    CoAP can also be used over TCP (draft currently in progress) which would then help (if the initial problem was NAT for example). But as of now, there is not keepalive mechanism in the draft. One would have to create its own using the same method I mentioned earlier.