NCS 2.6.0 Serial LTE modem at PCA10090 => Failed to work as a TCP server

Hi Nordic team

 At this link, it said nrf9160 can act as a TCP server. I followed the steps to test but TCP client failed to connect the server. 

https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/applications/serial_lte_modem/doc/slm_testing.html#tcp-ip-at-commands

What I did as below.

1. Connect nrf9160 to base station, Then, "AT+CGDCONT?" to ask its allocated IP address. So, IP address was "10.195.197.95".

Ready
> AT+CFUN=1

OK
> AT+CGDCONT?

+CGDCONT: 0,"IPV4V6","internet.iot","10.195.197.95 2001:B400:E20A:9F37:10A1:5A3C:8241:84D1",0,0

OK

2. Create a python script, named "client_tcp.py". The content was as same as sample code, except IP address and port number.

IP address was from step 1 "10.195.197.95".

3. Initialize TCP server to start listen

AT#XSOCKET=1,1,1

#XSOCKET: 0,1,6

OK

AT#XBIND=22 

OK

AT#XLISTEN

OK

4. Then, run the python script

5. Wait 60 sec to accept TCP client but failed.

- TCP server was timeout to accept TCP client.

AT#XACCEPT=60

ERROR

- At TCP client side (python terminal), it cannot connect TCP server and showed error message.

My questions

1. Anything incorrect in my steps?

2. According to below context, for TCP server, nrf9160 must have global private address.

   I have no idea what you mean and how to have "global private address". Could you explain?

3.  Besides, at every time "AT+CFUN=1", the carrier will assign new IP address to nrf9160.

     So, its address was not static. How can TCP client know correct IP address of TCP server before connecting?

Jeff

Parents
  • Hi Jeff,

    I have replicated the problem. I have also tested with different Python server and the connection to the server was successfully established. I think the issue might be related to addressing and accessibility of the device.

    1. Anything incorrect in my steps?

    It does not seem to be anything obviously wrong in your steps.

    2. According to below context, for TCP server, nrf9160 must have global private address.

       I have no idea what you mean and how to have "global private address". Could you explain?

    This does not seem to be correct. I will ask internally for clarification and potential correction.

    3.  Besides, at every time "AT+CFUN=1", the carrier will assign new IP address to nrf9160.

    Yes, this is correct. After each power off/on device gets new IP address from the network.

    I will get back to you when I get needed clarification, probably by the end of this week.

    Best regards,
    Dejan

  • Hi,

    "Global private address" should be changed to "public address". Commonly, device gets IPv4 address from the private range from the network operator and this address cannot be used for TCP server. You could try to use IPv6 address instead by using #XSOCKET=2,1,1. Then bind, listen, accept (as for IPv4) and use AF_INET6 instead of AF_INET. Machine running the script should also have its IPv6 address. 

    Best regards,
    Dejan

  • Hi Dejans

    1. How can we apply a public address for nrf9160? As far as I known, the only way nrf9160 connected to

        internet was through network operator. IPV4 or IPV6 addressed was private address assigned by network

        operator. It was confused. As I tested, at every time nrf9160 connects to network, "AT+CGDCONT?" got

        different IPV4 and IPV6 addresses.

    2.  I also tried IPV6 address as you mentioned.

    At TCP server side, got below IPV6 address

    Then, edited python script

    However, as ran this script, the terminal showed error message immediately.

    The Chinese sentence means the IPV6 address cannot be reached.

        

  • Hi,

    Have you used proper #XSOCKET command for opening a socket for IPv6, #XSOCKET=2,1,1?

    Best regards,
    Dejan

  • Yes. As below, "AT#XSOCKET=2,1,1".

    The result of connecting by IPV6 was different to IPV4.

    Using IPV4, TCP client (python script) did try to connect the server but timeout error.

    Using IPV6, script halted very soon and showed address cannot be connected.  It seems nothing about

    connecting timeout. 

    Did you ever try in your side?

  • Hi,

    Jeffery said:
    Did you ever try in your side?

    I have tested myself. I tried to reproduce your error but got the Timeout Error. However, we have tested this internally and result was successful. It might be that your operator does not allow incoming IPv6 (or IPv4) for your SIM card (which I assume also happens in my case). You could first try to test your IPv6 connectivity (for example by running "ping -6 ipv6.google.com") from your computer and if this is successful you can reach out to your network operator with further inquiries.

    Best regards,
    Dejan

Reply
  • Hi,

    Jeffery said:
    Did you ever try in your side?

    I have tested myself. I tried to reproduce your error but got the Timeout Error. However, we have tested this internally and result was successful. It might be that your operator does not allow incoming IPv6 (or IPv4) for your SIM card (which I assume also happens in my case). You could first try to test your IPv6 connectivity (for example by running "ping -6 ipv6.google.com") from your computer and if this is successful you can reach out to your network operator with further inquiries.

    Best regards,
    Dejan

Children
No Data
Related