iotcreators.com web
    • Login
    • Search
    • forum.iotcreators.com
    • docs.iotcreators.com
    • Tags
    • Popular
    • Recent
    • Register

    TCP listener remains occupied due to absence of read() and shutdown()?

    Network & Coverage
    tcp occupied
    1
    2
    47
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Adriaan last edited by

      I have this strange experience.

      In Holland, I am testing NB-IOT and CAT M1 SOS buttons, that work 100% on a Chinese platform, but as soon as I point the button to my clients Windows Azure server or my own Linux server, it keeps the TCP listener occuped. I guess it’s because the TCP connection is not properly closed, but I am not an expert here.

      I have tcpdumped my ass off, here is an strace of the processes:

      On my Linux, my listener is started like this:

      strace netcat -k -l

      Then in a normal sequence, I get this (strace output):

           0.000640 accept4(3, …
          20.274326 poll([{fd=0, events=POLLIN}, …
           0.003220 read(4, "MT;6;**TEST WEBSRV …
           0.000537 read(4, "", 16309)        = 0
           0.000304 shutdown(4, SHUT_RD)      = 0
           0.000282 write(1, "MT;6;**TEST WEBSRV …
           0.000354 close(4)                  = 0
      
      

      This is the problem causing one:

           0.000519 accept4(3, …
          12.447784 poll([{fd=0, events=POLLIN}, …
           0.092840 read(4, "MT;6;862785045411272;…
           0.000411 poll([{fd=0, events=POLLIN}, …
           0.000518 write(1, "MT;6;862785045411272;…
           0.000341 poll([{fd=0, events=POLLIN}, {fd=4, events=0}, {fd=4, events=POLLIN}, {fd=1, events=0}], 4, -1
      
      

      –> And the it waits forever, keeping my TCP listener occupied.

      I see the latter is not doing read() and shutdown(). I think that has to do with the button. Or can it be the T-Mobile network?

      I don’t get it. Maybe someone here?

      Thanks, Adriaan

      A 1 Reply Last reply Reply Quote 0
      • A
        Adriaan @Adriaan last edited by

        @Adriaan

        Well, at least I can reproduce the issue. On the sending side on Linux, the -N flag does the thing.

        echo "Hello there" | nc machine.domain <port> -N -v 2>&1
        

        When connecting to a remote host, and using strace -r -f netcat -k -l <port> , setting the -N flag results in

         0.000596 read(4, "", 16308)        = 0
         0.000354 shutdown(4, SHUT_RD)      = 0
        

        Without the -N flag, listener remains listening, and hence not closing the connection. This is the last line then:

        0.000404 poll([{fd=0, events=POLLIN}, {fd=4, events=0}, {fd=4, events=POLLIN}, {fd=1, events=0}], 4, -1
        

        Next step is that I am going to look if I can change something on the listener side as well.

        Greetz,

        Adriaan

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post