<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CoAP with DTLS on nRF9151</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/129247/coap-with-dtls-on-nrf9151</link><description>Dear Nordic team, 
 I am struggling to set up CoAP with DTLS for a Thingsboard CoAP backend. The connection works just fine when using plain UDP, but when I set up a socket with DTLS I run into an error, where the CoAP client request responds with error</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 24 Sep 2026 18:38:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/129247/coap-with-dtls-on-nrf9151" /><item><title>RE: CoAP with DTLS on nRF9151</title><link>https://devzone.nordicsemi.com/thread/571570?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2026 18:38:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:040e646b-2b72-460c-8f3e-f4ce01d1d5d5</guid><dc:creator>Achim Kraus</dc:creator><description>&lt;p&gt;If you provide an ip-capture/wireshark, we will see, what happens exactly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS on nRF9151</title><link>https://devzone.nordicsemi.com/thread/571563?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2026 16:24:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb1d0076-a95e-4063-8fb3-a484965596de</guid><dc:creator>Syed Maysum Abbas Zaidi</dc:creator><description>&lt;p&gt;Hi Tom,&lt;/p&gt;
&lt;p&gt;Good to know it worked.&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;tested your pattern, TLS_SESSION_CACHE on a new DTLS socket, connect(), then coap_client_req close and repeat. However TLS_DTLS_HANDSHAKE_STATUS was&amp;nbsp;full on two connects, so&amp;nbsp;I did not see session resumption on my test server (not ThingsBoard). The cache option applies to DTLS like HTTPS, but I think resumption depends on the&amp;nbsp;server side&amp;nbsp;so I would suggest you&amp;nbsp;to try on your ThingsBoard.&lt;/p&gt;
&lt;p&gt;I am checking details about your second question and will get back to you&amp;nbsp;by tomorrow. Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS on nRF9151</title><link>https://devzone.nordicsemi.com/thread/571560?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2026 15:13:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cb5d504-54d6-4e54-a7a4-1276391bf021</guid><dc:creator>Achim Kraus</dc:creator><description>&lt;p&gt;&amp;gt;&amp;nbsp;Our application will probably have to renew the socket regularly&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Why?&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;nbsp;I am not yet sure if we will be able to use CID for session resumptions.&lt;/p&gt;
&lt;p&gt;CID is not related to session resumption. CID rather obsoletes session resumption in the most cases.&lt;/p&gt;
&lt;p&gt;The nasty point in Nordic&amp;#39;s DTLS modem implementation is, that the DTLS state is bound to the socket. If that socket closes, the state is usually gone. I don&amp;#39;t know, If there is a way to preserve it, but Nordic will know it.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS on nRF9151</title><link>https://devzone.nordicsemi.com/thread/571546?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2026 12:22:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c611f516-117a-4444-807f-4163e90bc9f0</guid><dc:creator>Tom01</dc:creator><description>&lt;p&gt;Hey Syed,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;thanks for the response. I just updated to NCS v3.4.1 and now confirmable requests work! Thanks!&lt;/p&gt;
&lt;p&gt;For the record and for the AI: CoAP with DTLS works when the socket is created, socket options for DTLS are applied and the socket is then connected manually. When using the CoAP client API, it is important to then pass NULL as the &amp;quot;addr&amp;quot; argument in the &amp;quot;coap_client_req()&amp;quot; method. This works on NCS v3.4.1.&lt;/p&gt;
&lt;p&gt;Furthermore I have two additional questions:&lt;/p&gt;
&lt;p&gt;1. Our application will probably have to renew the socket regularly and I am not yet sure if we will be able to use CID for session resumptions. For general TLS session resumption with HTTPS the following seems to work:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int32_t cache_enabled = 1;
err = setsockopt(
    fd, NRF_SOL_SECURE, NRF_SO_SEC_SESSION_CACHE, &amp;amp;cache_enabled, sizeof(cache_enabled));
if (err) {
	printk(&amp;quot;Failed to enable TLS session cache, err %d\n&amp;quot;, errno);
	return err;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Would this also apply to DTLS session resumption in the CoAP case?&lt;/p&gt;
&lt;p&gt;2. I was wondering how PSM and eDRX settings affect the inner workings of the CoAP client. We do not plan to use observe functionality. Would settings like&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# PSM
CONFIG_LTE_LC_PSM_MODULE=y
CONFIG_LTE_PSM_REQ=y
# PSM Periodic TAU (2 hours)
CONFIG_LTE_PSM_REQ_RPTAU=&amp;quot;00100010&amp;quot;
# PSM Active Time (22 seconds)
CONFIG_LTE_PSM_REQ_RAT=&amp;quot;00001011&amp;quot;
# eDRX
CONFIG_LTE_LC_EDRX_MODULE=y
CONFIG_LTE_EDRX_REQ=y
# eDRX Cycle: &amp;quot;0000&amp;quot; = 5.12 s, &amp;quot;0010&amp;quot; = 20.48 s
CONFIG_LTE_EDRX_REQ_VALUE_LTE_M=&amp;quot;0010&amp;quot;
CONFIG_LTE_EDRX_REQ_VALUE_NBIOT=&amp;quot;0010&amp;quot;
# Paging Time Window (PTW): &amp;quot;0011&amp;quot; = 5.12 s for LTE-M / 10.24 s for NB-IoT
CONFIG_LTE_PTW_VALUE_LTE_M=&amp;quot;0011&amp;quot;
CONFIG_LTE_PTW_VALUE_NBIOT=&amp;quot;0011&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;cause conflicts with the timeout and retry behavior of the CoAP client if the modem successfully negotiates them?&lt;/p&gt;
&lt;p&gt;Thanks again and best,&lt;/p&gt;
&lt;p&gt;Tom&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS on nRF9151</title><link>https://devzone.nordicsemi.com/thread/571528?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2026 08:57:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e55ab751-63ee-4052-822a-c9b7c975a4f0</guid><dc:creator>Syed Maysum Abbas Zaidi</dc:creator><description>&lt;p&gt;Hi Tom,&lt;/p&gt;
&lt;p&gt;Thanks for the detailed CoAP debug log, it matches what we see here.&lt;/p&gt;
&lt;p&gt;On nRF9151 with your approach (DTLS, connect(), NULL address to coap_client_req()), we see the same behaviour on NCS v3.4.0 the request and response complete, then sending the empty ACK fails (Error sending a CoAP ACK-message, -106 in the callback). The same application on NCS v3.4.1 works without that error.&lt;/p&gt;
&lt;p&gt;Your tests with non-confirmable requests fit this, that path does not hit the same ACK handling. This does not indicate that confirmable CoAP is unsupported on the modem, I think it points to a CoAP client issue on v3.4.0 when acknowledging a confirmable response on a connected DTLS socket. So recommendation is to move to NCS v3.4.1. Do let me know if it runs without error on it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS on nRF9151</title><link>https://devzone.nordicsemi.com/thread/571518?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2026 06:24:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b26eb7dc-7797-4627-b45b-b80fc0e3b546</guid><dc:creator>Achim Kraus</dc:creator><description>&lt;p&gt;-106 =&amp;gt;&amp;nbsp;#define EAFNOSUPPORT 106&amp;nbsp; &amp;nbsp; /* Address family not supported by protocol family */&lt;/p&gt;
&lt;p&gt;I would check the &amp;quot;dest_addr&amp;quot;, &amp;quot;addrlen&amp;quot; parameters.&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;nbsp;I am wondering if the modem rejects that specific message for some reason.&lt;/p&gt;
&lt;p&gt;I never recognized that in all the years (sending a couple 10.000 ACKs).&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;nbsp;When using a non-confirmable request, no errors occur. I&amp;#39;ve confirmed this with GET and POST requests. Data is read from and written to Thingsboard successfully.&lt;/p&gt;
&lt;p&gt;That&amp;#39;s more a indirect effect. ThingsBoard uses a &amp;quot;Separate Response&amp;quot;, a &amp;quot;Piggybacked Response&amp;quot; would work without such an &amp;quot;ACK for Response&amp;quot;.&lt;/p&gt;
&lt;p&gt;Also not sure, if you want to use observe/notify and therefore the Responses (Notification) may be sent as CON (from time to time to check the interest). In my experience, NATs makes observe/notify pretty frequently useless. We discussed that years ago in the IETF core list.&lt;/p&gt;
&lt;p&gt;In the end, if your client is designed for &amp;quot;very low energy consumption&amp;quot;, it will frequently sleep for long. Depending on your network setup, that may already cause ip-address changes and usually makes observe/notify not longer working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS on nRF9151</title><link>https://devzone.nordicsemi.com/thread/571491?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2026 13:22:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26010b53-b206-4765-88f7-b0d613e0ee3e</guid><dc:creator>Tom01</dc:creator><description>&lt;p&gt;I&amp;#39;ve found time to trouble-shoot this more and I think the CoAP library debug logs might reveal where the problem lies. With the request set to confirmable, the log seems to show that the request is successfully transmitted, the response successfully received, but the acknowledgement cannot be returned:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:07.596,099] &amp;lt;inf&amp;gt; coaps: IPv4 Address found 3.127.76.36
[00:00:07.596,405] &amp;lt;inf&amp;gt; coaps: sa_family = 1
[00:00:10.778,137] &amp;lt;dbg&amp;gt; net_coap: coap_client_req: Request is_observe 0
[00:00:10.778,198] &amp;lt;dbg&amp;gt; net_coap: send_request: Send CoAP Request:
                                   REDACTED_TO_HIDE_ACCESS_TOKEN 
[00:00:10.779,632] &amp;lt;inf&amp;gt; main_app: waiting
[00:00:11.101,684] &amp;lt;dbg&amp;gt; net_coap: receive: Receive CoAP Response:
                                   48 45 0c 6e 2b 8a 67 c9  42 04 52 63 c1 32 ff 7b |HE.n+.g. B.Rc.2.{
                                   22 73 68 61 72 65 64 22  3a 7b 22 73 64 6c 43 6f |&amp;quot;shared&amp;quot; :{&amp;quot;sdlCo
                                   6e 66 69 67 54 73 22 3a  36 7d 7d                |nfigTs&amp;quot;: 6}}     
[00:00:11.101,715] &amp;lt;dbg&amp;gt; net_coap: recv_response: Received 43 bytes
[00:00:11.101,745] &amp;lt;dbg&amp;gt; net_coap: send_request: Send CoAP Request:
                                   60 00 0c 6e                                      |`..n             
[00:00:11.101,776] &amp;lt;err&amp;gt; net_coap: Error sending a CoAP ACK-message
[00:00:11.101,806] &amp;lt;inf&amp;gt; main_app: Response received with error code: -106
[00:00:11.101,837] &amp;lt;inf&amp;gt; main_app: sleeping
[00:00:11.101,898] &amp;lt;err&amp;gt; net_coap: Error handling response
[00:00:13.669,830] &amp;lt;dbg&amp;gt; net_coap: receive: Receive CoAP Response:
                                   48 45 0c 6e 2b 8a 67 c9  42 04 52 63 c1 32 ff 7b |HE.n+.g. B.Rc.2.{
                                   22 73 68 61 72 65 64 22  3a 7b 22 73 64 6c 43 6f |&amp;quot;shared&amp;quot; :{&amp;quot;sdlCo
                                   6e 66 69 67 54 73 22 3a  36 7d 7d                |nfigTs&amp;quot;: 6}}     
[00:00:13.669,860] &amp;lt;dbg&amp;gt; net_coap: recv_response: Received 43 bytes
[00:00:13.669,921] &amp;lt;dbg&amp;gt; net_coap: send_request: Send CoAP Request:
                                   60 00 0c 6e                                      |`..n             
[00:00:13.669,921] &amp;lt;err&amp;gt; net_coap: Error sending a CoAP ACK-message
[00:00:13.669,952] &amp;lt;inf&amp;gt; main_app: Response received with error code: -106
[00:00:13.669,952] &amp;lt;err&amp;gt; net_coap: Error handling response&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When using a non-confirmable request, no errors occur. I&amp;#39;ve confirmed this with GET and POST requests. Data is read from and written to Thingsboard successfully.&lt;/p&gt;
&lt;p&gt;After having a look at the library&amp;#39;s code where this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static int send_ack(int sock_fd, const struct net_sockaddr *addr, net_socklen_t addrlen,
		    const struct coap_packet *req, uint8_t response_code)
{
	int ret;
	struct coap_packet ack;
	uint8_t ack_buf[COAP_FIXED_HEADER_SIZE + COAP_TOKEN_MAX_LEN];

	ret = coap_ack_init(&amp;amp;ack, req, ack_buf, sizeof(ack_buf), response_code);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to initialize CoAP ACK-message&amp;quot;);
		return ret;
	}

	ret = send_request(sock_fd, ack.data, ack.offset, 0, addr, addrlen);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;Error sending a CoAP ACK-message&amp;quot;);
		return ret;
	}

	return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;seems to produce the error message, because this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static int send_request(int sock, const void *buf, size_t len, int flags,
			const struct net_sockaddr *dest_addr, net_socklen_t addrlen)
{
	int ret;

	LOG_HEXDUMP_DBG(buf, len, &amp;quot;Send CoAP Request:&amp;quot;);
	if (addrlen == 0) {
		ret = zsock_sendto(sock, buf, len, flags, NULL, 0);
	} else {
		ret = zsock_sendto(sock, buf, len, flags, dest_addr, addrlen);
	}

	return ret &amp;gt;= 0 ? ret : -errno;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;throws the error when trying to write the ACK (&amp;quot;60 00 0c 6e&amp;quot;) to the socket, I am wondering if the modem rejects that specific message for some reason. I think that this is not a general socket issue, because I can reuse the socket for multiple following requests successfully. It just seems to reject only the ACK.&lt;/p&gt;
&lt;p&gt;Do you have an idea why this happens? Are confirmable packets not supported via the modem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS on nRF9151</title><link>https://devzone.nordicsemi.com/thread/571470?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2026 09:55:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8834c3c-a7c4-4fed-98af-28ae8d8f87ba</guid><dc:creator>Tom01</dc:creator><description>&lt;p&gt;Hi Syed,&lt;/p&gt;
&lt;p&gt;thanks for trying out the sample! I&amp;#39;m using modem firmware v2.0.4.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;One more thing that might cause the 106 errors inside the callback, is the path length of the request. Because of the API structure and the access token, the path is 62 characters long in this particular case. I&amp;#39;m not sure if this might be an issue, but just for the sake of completeness, here are the CoAP settings I use:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_COAP=y
CONFIG_COAP_CLIENT=y
CONFIG_COAP_CLIENT_THREAD_PRIORITY=10
CONFIG_COAP_CLIENT_MESSAGE_SIZE=512
CONFIG_COAP_CLIENT_MESSAGE_HEADER_SIZE=128
CONFIG_COAP_CLIENT_MAX_PATH_LENGTH=128&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best,&lt;/p&gt;
&lt;p&gt;Tom&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CoAP with DTLS on nRF9151</title><link>https://devzone.nordicsemi.com/thread/571469?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2026 09:43:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcd6b691-87ec-463b-8fe3-3361c3036050</guid><dc:creator>Syed Maysum Abbas Zaidi</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for reaching out.&lt;/p&gt;
&lt;p&gt;I am trying out on my end and will get back to you soon. Although not very important, can you share the modem firmware version you are using?&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;br /&gt;Syed Maysum&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>