1COAP_KEEPALIVE(3)               libcoap Manual               COAP_KEEPALIVE(3)
2
3
4

NAME

6       coap_keepalive, coap_context_set_keepalive - Work with CoAP keepalive
7

SYNOPSIS

9       #include <coap3/coap.h>
10
11       void coap_context_set_keepalive(coap_context_t *context, unsigned int
12       seconds);
13
14       For specific (D)TLS library support, link with -lcoap-3-notls,
15       -lcoap-3-gnutls, -lcoap-3-openssl, -lcoap-3-mbedtls or
16       -lcoap-3-tinydtls. Otherwise, link with -lcoap-3 to get the default
17       (D)TLS library support.
18

DESCRIPTION

20       There may be a requirement to send out keepalive traffic when the CoAP
21       session is idle (no packets have been sent or received for a specified
22       period) to keep, say, an interim NAT device "warm" with the NAT
23       translation state, or to periodically check whether the device at the
24       other end of the session has "gone away".
25
26       For UDP/DTLS, this is done with the confirmable CoAP (0.00) Ping
27       packet, which solicits a CoAP RST response. For TCP/TLS, this is done
28       with CoAP (7.02) Ping packet, which solicits a CoAP (7.03) Pong
29       response, all handled by libcoap.
30
31       The coap_context_set_keepalive() function needs to be called to update
32       the context with the keepalive for idle traffic timeout of seconds. If
33       seconds is set to 0 (the default), then the sending of keepalives is
34       disabled. Any sessions created from this context will use the same
35       seconds value to determine whether a keepalive "ping" is to be sent out
36       or not.
37
38       Applications can track the usage of the receipt of "pings" and receipt
39       of "responses" by defining the respective handlers to use by using
40       coap_register_ping_handler() and coap_register_pong_handler().
41
42       If the keepalive fails to solicit a response, then this can be tracked
43       by defining the handler to use by using coap_register_nack_handler()
44       which will be called with a reason of COAP_NACK_TOO_MANY_RETRIES.
45
46       NOTE: coap_context_set_keepalive() is supported by both the CoAP client
47       and CoAP server.
48

SEE ALSO

50       coap_handler(3)
51

FURTHER INFORMATION

53       "RFC7252: The Constrained Application Protocol (CoAP)"
54
55       "RFC8323: CoAP (Constrained Application Protocol) over TCP, TLS, and
56       WebSockets"
57

BUGS

59       Please report bugs on the mailing list for libcoap:
60       libcoap-developers@lists.sourceforge.net or raise an issue on GitHub at
61       https://github.com/obgm/libcoap/issues
62

AUTHORS

64       The libcoap project <libcoap-developers@lists.sourceforge.net>
65
66
67
68coap_keepalive 4.3.0              01/20/2022                 COAP_KEEPALIVE(3)
Impressum