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 Dhaval,

    After replacing IP address in STATIC_IP_STR, I have managed to build (using "west build -b nrf9160dk_nrf9160_ns -d build" command in VS Code) and flash your application to nrf9160-dk in NCS v2.6.0 but the log error that I got (shown below) is different than yours

    <inf> CoAP_APP: coap_service_start : -114
    <inf> CoAP_APP: coap_service_is_running : 0
    <inf> main: [67]StartTCPServer
    <inf> main: [75]StartTCPServer >> socket >> serv >> 2
    <err> main: error: bind: 114

    Is there anything else missing? Should anything else be changed?

    Best regards,
    Dejan

  • Hi Dejan Simonovic,

    look like you have not posted complete log file, is network registered successfully ?

    I have tested same code by commented network register process code and i got same log as yours, so i think, network might not registered in your case.

    Please use below log as reference, it shows text during network registration is on going

    *** Booting nRF Connect SDK v3.5.99-ncs1 ***
    [00:00:00.333,648] <inf> main: [142]main
    [00:00:02.605,895] <inf> main: RSP : +CEREG: 0,4
    OK
    
    [00:00:03.614,898] <inf> main: RSP : +CEREG: 0,2,"2BDC","0340830A",7
    OK
    
    [00:00:04.623,931] <inf> main: RSP : +CEREG: 0,2,"2BDC","0340830A",7
    OK
    
    [00:00:05.624,572] <inf> main: RSP : +CEREG: 0,2,"2BDC","0340830A",7
    OK
    
    [00:00:06.625,427] <inf> main: RSP : +CEREG: 0,2,"2BDC","0340830A",7
    OK
    
    [00:00:07.626,007] <inf> main: RSP : +CEREG: 0,1,"2BDC","0340830A",7
    OK
    
    [00:00:07.626,647] <inf> CoAP_APP: coap_service_start : 0
    [00:00:08.626,708] <inf> CoAP_APP: coap_service_is_running : 1
    [00:00:09.626,922] <inf> main: [67]StartTCPServer
    [00:00:09.626,953] <inf> main: Project : CoAPAndServer
    [00:00:09.627,349] <inf> main: [76]StartTCPServer >> socket >> serv >> 3
    [00:00:09.627,685] <inf> main: Started TCP server example on port 502, 0
    [00:00:09.627,716] <err> main: error: accept: 23, -1
    [00:00:09.827,850] <err> main: error: accept: 23, -1
    [00:00:10.027,984] <err> main: error: accept: 23, -1

    thanks,

    Dvl

  • Hi Dvl,

    Does your application require static IP address? Could the reason for seeing different output be that I tested using SIM card which does not have public static IP address?

    Best regards,
    Dejan

  • Hi Dejan Simonovic,

    My SIM is static SIM, but I updated code and it will work for any SIM now, so please try this following one,

    CoAPAndTCPServer_v0.1.zip

    Thanks,

    Dvl

  • Hi Dvl,

    I am not able to reproduce what you see on my nrf9160-dk board.
    I have built (for board target nrf9160dk_nrf9160_ns) and flashed your modified project to nrf9160-dk board using NCS v2.6.0. I am continuously getting
    "<inf> main: RSP : +CEREG: 0,2, ..." message in the terminal output.
    Do you get the same when using nrf9160-dk board?
    I hope that you can modify your project further so that I can replicate what you see. Alternatively, you could try to make a minimal sample which demonstrates the behavior and has reproducible output.

    Best regards,
    Dejan

Related