This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

What does error 23 - ENFILE mean?

Hi, 

I am using the nRF9160 on a custom PCB, SDK version 1.6.1 and modem FW 1.3.1

My Application uses MQTT to send messages to a server at regular intervals. In between messages it goes into Power saving mode. Over the last 4 days we have put a few units on a long term test and found 2 or the 3 have experienced an issue with a File Table Overflow - Error 23 ENFILE. 

Unfortunately neither units recovered after experiencing this error. It seems to happen at the point it tries to reconnect to the MQTT broker, and I cant find exactly where in the code it happens as it took a couple of days before this error happened. 

If I reset the unit, it reconnects to the network and and successfully starts sending MQTT messages again. 

Question is - What does 'File Table Overflow' mean, and what is the correct way to deal with this error?

Thanks, 

Damien

Parents
  • Hi,

     

    My Application uses MQTT to send messages to a server at regular intervals. In between messages it goes into Power saving mode. Over the last 4 days we have put a few units on a long term test and found 2 or the 3 have experienced an issue with a File Table Overflow - Error 23 ENFILE. 

    Unfortunately neither units recovered after experiencing this error. It seems to happen at the point it tries to reconnect to the MQTT broker, and I cant find exactly where in the code it happens as it took a couple of days before this error happened. 

    If I reset the unit, it reconnects to the network and and successfully starts sending MQTT messages again. 

    Question is - What does 'File Table Overflow' mean, and what is the correct way to deal with this error?

    It depends on what call that reports this error back, but I have a feeling that it is the socket() call that might return this error on your end?

    https://github.com/nrfconnect/sdk-nrf/blob/v1.6.1/lib/nrf_modem_lib/nrf91_sockets.c#L1322

    ENFILE returned after creating a socket indicates that you're not closing the former sockets, or that you have several sockets open simultaneously (D/TLS has max. 3 sockets simultaneously). 

    Do you have a log that shows the issue?

     

    Kind regards,

    Håkon 

  • Hi Hakon, 

    Unfortunately I don't have a log. My code is based on the simple_mqtt sample. It fails on the function mqtt_connect()

    We are testing units in an underground chamber so signal will be poor. I am wondering if it happens when signal is so low that the unit disconnects from the network and doesn't close the socket correctly. 

    I think maybe I need to create a flag to ensure that it has gone through the mqtt_disconnect() function before it tries to do a connect again. 

    If the error persists, is there a nice function to close all open sockets?

    Thanks, 

    Damien

  • Hi Damien,

     

    DamoL said:
    We are testing units in an underground chamber so signal will be poor.

    Are you checking the lte link status before connecting? 

    DamoL said:
    If the error persists, is there a nice function to close all open sockets?

    mqtt shall close the socket if a error occurs on any write/read function.

    If you call mqtt_connect() without disconnecting your current connection, you will overwrite the socket_fd:

    https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.99-ncs1-1/subsys/net/lib/mqtt/mqtt_transport_socket_tcp.c#L26

    So it is very important that you disconnect your current link before calling mqtt_connect() again.

     

    DamoL said:
    If the error persists, is there a nice function to close all open sockets?

    socket fd is stored in the application. The modem only allows for 3 (D/TLS based streams) to be open at the same time, so if there's not a sufficient clean-up in the application, you'll have dormant sockets that are open. There's no API to directly kill all the sockets, but if you disable/enable the modem (using AT+CFUN for instance), this should be cleared.

     

    Kind regards,

    Håkon

Reply
  • Hi Damien,

     

    DamoL said:
    We are testing units in an underground chamber so signal will be poor.

    Are you checking the lte link status before connecting? 

    DamoL said:
    If the error persists, is there a nice function to close all open sockets?

    mqtt shall close the socket if a error occurs on any write/read function.

    If you call mqtt_connect() without disconnecting your current connection, you will overwrite the socket_fd:

    https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.99-ncs1-1/subsys/net/lib/mqtt/mqtt_transport_socket_tcp.c#L26

    So it is very important that you disconnect your current link before calling mqtt_connect() again.

     

    DamoL said:
    If the error persists, is there a nice function to close all open sockets?

    socket fd is stored in the application. The modem only allows for 3 (D/TLS based streams) to be open at the same time, so if there's not a sufficient clean-up in the application, you'll have dormant sockets that are open. There's no API to directly kill all the sockets, but if you disable/enable the modem (using AT+CFUN for instance), this should be cleared.

     

    Kind regards,

    Håkon

Children
No Data
Related