<?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>Error -23 in mqtt_connect</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/127130/error--23-in-mqtt_connect</link><description>Good afternoon, 
 My device communicates using MQTT a few times a day. After many connections I noticed that communications stopped. Every connection attempt would fail with: 
 Error in mqtt_connect: -23. 
 Error code 23 corresponds to &amp;quot;file table overflow</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 16 Mar 2026 10:02:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/127130/error--23-in-mqtt_connect" /><item><title>RE: Error -23 in mqtt_connect</title><link>https://devzone.nordicsemi.com/thread/563303?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2026 10:02:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:385dec59-da3d-4f8d-978d-8698c344fc2f</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As seen from the code, mqtt_abort() wraps around mqtt_disconnect() with a if-sentence:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="hkn"]&lt;p&gt;This function will only disconnect if the mqtt state is not idle:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/net/lib/mqtt/mqtt.c#L689-L702"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/net/lib/mqtt/mqtt.c#L689-L702&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would recommend that you call mqtt_disconnect() directly to ensure socket cleanup.&lt;/p&gt;[/quote]
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error -23 in mqtt_connect</title><link>https://devzone.nordicsemi.com/thread/563301?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2026 09:55:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afd25c81-58d7-4239-b2a9-deeef7ec1806</guid><dc:creator>Bastien42</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I believe that mqtt_disconnect() may return without closing the socket in case of errors, in such cases calling mqtt_abort() will close the socket.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bastien Neukomm&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error -23 in mqtt_connect</title><link>https://devzone.nordicsemi.com/thread/562534?ContentTypeID=1</link><pubDate>Wed, 04 Mar 2026 11:11:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:425c3d2f-ab0c-4b83-9fb3-c5818eac390d</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Bastien42"]I am currently using a nRF9160 with NCS 2.7.0 and I don&amp;#39;t think that&amp;nbsp;CONFIG_ZVFS_POLL_MAX exists in that version.[/quote]
&lt;p&gt;Check the value of config &amp;quot;CONFIG_POSIX_MAX_FDS&amp;quot;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As you mention, if left untouched, it should not be a problem, however; if you are concurrently maintaining&amp;nbsp;several asynchronous connections; please see the restrictions in the release notes.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error -23 in mqtt_connect</title><link>https://devzone.nordicsemi.com/thread/562457?ContentTypeID=1</link><pubDate>Tue, 03 Mar 2026 15:13:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1160fc38-4c0b-48c8-9a6d-14cff4a877c4</guid><dc:creator>Bastien42</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am currently using a nRF9160 with NCS 2.7.0 and I don&amp;#39;t think that&amp;nbsp;CONFIG_ZVFS_POLL_MAX exists in that version. I suppose that i have a default value for the corresponding parameter&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bastien&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error -23 in mqtt_connect</title><link>https://devzone.nordicsemi.com/thread/562397?ContentTypeID=1</link><pubDate>Tue, 03 Mar 2026 09:37:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fab23950-9a98-454a-9d04-e589f6f086de</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes, other concurrent connections should be considered.&lt;/p&gt;
&lt;p&gt;Please see here for the restrictions of the modem firmware when it comes to concurrent connections, especially if they are secure sockets:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/dev-kits/nrf9160-dk/release_notes_modemfirmware/mfw_nrf9160_1.3.7_release_notes.txt"&gt;https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/dev-kits/nrf9160-dk/release_notes_modemfirmware/mfw_nrf9160_1.3.7_release_notes.txt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is your current &amp;quot;CONFIG_ZVFS_POLL_MAX&amp;quot; set to? You can try to increase this slightly, in case it is the kernel&amp;#39;s fd table that is overflowing.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error -23 in mqtt_connect</title><link>https://devzone.nordicsemi.com/thread/562328?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2026 13:44:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:363f64bb-0153-4a8a-931b-5e0cd6fa81bf</guid><dc:creator>Bastien42</dc:creator><description>&lt;p&gt;Yes sure, do connections to nRF Cloud via MQTT can also be source of problems ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error -23 in mqtt_connect</title><link>https://devzone.nordicsemi.com/thread/562326?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2026 13:41:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d45a305-7b94-46a7-96b0-babbb866d804</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Bastien42"]Okay, I tried it, i still seem to have an edge case where sockets are not closed properly.[/quote]
&lt;p&gt;Please note that each mqtt_connect() will effectively setup a new fd:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/net/lib/mqtt/mqtt_transport_socket_tcp.c#L21-L30"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/net/lib/mqtt/mqtt_transport_socket_tcp.c#L21-L30&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would recommend that you check if your firmware has any scenarios where it re-connects without closing/disconnecting the former socket successfully.&lt;/p&gt;
[quote user="Bastien42"]Do you know how to properly monitor the fd table ? I think that this will help me to get to the problem.[/quote]
&lt;p&gt;Looking at zephyr/sys/fdtable.h, it does not seem that there is an API directly to do this, unfortunately.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error -23 in mqtt_connect</title><link>https://devzone.nordicsemi.com/thread/562289?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2026 09:26:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b30b72b0-fe25-4da6-8c59-359f8252a7a9</guid><dc:creator>Bastien42</dc:creator><description>&lt;p&gt;Okay, I tried it, i still seem to have an edge case where sockets are not closed properly.&lt;/p&gt;
&lt;p&gt;Do you know how to properly monitor the fd table ? I think that this will help me to get to the problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error -23 in mqtt_connect</title><link>https://devzone.nordicsemi.com/thread/561834?ContentTypeID=1</link><pubDate>Mon, 23 Feb 2026 13:07:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9a6a5e8-a940-447f-97db-486231c5f478</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;This function will only disconnect if the mqtt state is not idle:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/net/lib/mqtt/mqtt.c#L689-L702"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/net/lib/mqtt/mqtt.c#L689-L702&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would recommend that you call mqtt_disconnect() directly to ensure socket cleanup.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error -23 in mqtt_connect</title><link>https://devzone.nordicsemi.com/thread/561831?ContentTypeID=1</link><pubDate>Mon, 23 Feb 2026 13:00:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2f6a324-6bf2-45d9-8a65-502b0c3a12fd</guid><dc:creator>Bastien42</dc:creator><description>&lt;p&gt;Thanks for this rapid answer.&lt;/p&gt;
&lt;p&gt;Okay, I will implement that.&lt;/p&gt;
&lt;p&gt;Is mqtt_abort() even useful in my case ? Should I try to use mqtt_disconnect only ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error -23 in mqtt_connect</title><link>https://devzone.nordicsemi.com/thread/561830?ContentTypeID=1</link><pubDate>Mon, 23 Feb 2026 12:57:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:baf9c126-4be2-444a-a175-6ba328fdfbce</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The socket is closed when you call mqtt_disconnect(), as this will then subsequently call close():&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/net/lib/mqtt/mqtt_transport_socket_tcp.c#L167"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/net/lib/mqtt/mqtt_transport_socket_tcp.c#L167&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Similar for TLS:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c#L249"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c#L249&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It is very important that you close a socket before initiating a new connection, to avoid overflowing the fd table.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>