How to solve socket -23 error while creating multiple server in nRF9160

Hi Support team,

I am  using nRF9160 module and i want run two server on the module, one is modbus server and other is CoAP server. so is it possible to run both server simultaneously ?

Thanks,

Dvl

  • Hi Dvl,

    I have managed to replicate the error. However, I also got IP address error which I do not see in your log. Could this also be due to IP address not being static?

    Below is my log.

    <err> main: [311]IP_Address_str : 10.61.100.236
    <inf> CoAP_APP: coap_service_start : 0
    <inf> CoAP_APP: coap_service_is_running : 1
    <inf> main: [171]StartTCPServer
    <inf> main: [187]StartTCPServer >> socket >> serv >> 3
    <inf> main: Started TCP server example on port 502, 0
    <err> main: error: accept: 23, -1
    <err> main: error: accept: 23, -1
    



    Best regards,
    Dejan

  • Hi Dejan Simonovic, thanks for your effort. 

    1. Its good news that you got same log as mine, Please now help me to solve this issue.

    2. Please ignore IP Address error, because that log is just for information. by mistake, I used LOG_ERR() that's a reason it showing this log as error, i am sorry for that.

    3. I changed that log tag and created another version of code, please use below code if you want.

    CoAPAndTCPServer_v0.3.zip

    thanks,

    Dvl

  • Hi Dvl,

    Maximum number of file descriptors is 4 by default and they are all allocated which means that the application runs out of descriptors. When calling accept(), it would return a new STREAM (TCP) socket for every incoming connection. This means that Zephyr runs out of file descriptors even before modem runs out of sockets (5). You could try to increase ZFVS_OPEN_MAX to 8 (5 for sockets on nRF91 side plus 2 for socketpair() plus one extra).

    Best regards,
    Dejan

  • Hi Dejan

    thanks for this information,

    1. I added CONFIG_ZVFS_OPEN_MAX=8 in my "prj.conf" file but it is showing error that this is unknow macro, so i went to 'lib/os/Kconfig:13'(as per ZFVS_OPEN_MAX) this path but there is nothing like that config option. FYI, i am using nRF SDK 2.6.0.

    2. Have you test this by updating ZFVS_OPEN_MAX macro value? please Guide me how and where to increase this value.

    Thanks,

    Dvl

  • Hi Dejan

    Thanks for your support,

     

    I was able to increase Max FDs, using macro CONFIG_POSIX_MAX_FDS, I have added CONFIG_POSIX_MAX_FDS=8 line in 'prj.conf' file. now both server are running ok.

     

    thanks again for your kind support.

    Thanks,

    Dvl

Related