[SOLVED] Socket communication using the _socket module

14 thoughts on “[SOLVED] Socket communication using the _socket module

  1. Now that we switched to a Python 2.7-enabled module we were planning on replacing the AT based socket communication to simplify and streamline the implementation. I have confgured (CGDCONT) and activated (SGACT) the context, and bound it to the socket object using setsockopt and SO_CONTEXTID. However, it seems to time out when I try to connect. Using raw AT commands works.


    Are there any examples available or am I missing something?

  2. I agree with Cosmin: post a test script demonstrating the problem.

    Furthermore I don’t know if you are already using the Python debug output on HE910 available on USIF1 using at#portcfg=3 configuration (look at the Telit_HE910_UE910_Family_Ports_Arrangements_r6 user guide available on UMTS Telit products web page)

    1. Sorry for the extreme delay on this. I’m not sure I’ve done everything correctly in this test, but please have a look at the attached file. When I execute it on the computer it connects to google.com just fine, but on the modem it gives me this:







      Python 2.7.2 (default, OCT 13 2011, 17:11:00) [C] on UL865-EUR

      import _socket # builtin

      import time # builtin

      import MDM # builtin

      –> ATE0

      <– OK

      –> AT+CMEE=1

      <– OK

      –> AT#SELINT=2

      <– OK

      –> AT+CGDCONT=1,"IP","internet.telenor.se"

      <– OK

      –> AT#USERID="user"

      <– OK

      –> AT#PASSW=""

      <– OK

      –> AT#GPRS=1

      <– +CME ERROR: 553

      ERROR: Reply missing

      –> AT#CGPADDR=1

      <– #CGPADDR: 1,"" 




      Finally resulting in (stack trace was a bit too long for my terminal):


      ttest.py", line 47, in <module>

          s.connect((‘www.google.com’, 80))

      socket.error: [Errno 110] Unknown error 




        1. If it’s random, it could be related to a connection timeout of the net.

          The connection with a GPRS net in the middle does not have the same speed of a "direct" connection to internet, and this behavior may not be avoidable.


          Otherwise (if it is systematic) Telit needs to collect log of the behavior with proprietary diagnostic tool. In this case you should refere to Cosmin in a first instance

          1. Hi Marco,

            you can find enclosed a modified version of your script (rename txt in py).


            the main modifications:

            – increased wating time for the answer 

            – added the command  AT#FRWL=1,"",""

            –  AT#SGACT=1,1 in place of AT#GPRS=1 (old)


            Please try it and post if you observe any improvement








          2. Hi,


            when you use the AT commands  only (without Python), the firewall is automatically configured to exchange data only from that IP address.

            On AT interface if it’s necessary to exchange data with other IP addresses then it’s necessary to use AT#FRWL command 


            In Python the firewall is not configured automatically.

      1. If it’s random, it seems a message relating  to Connection timed out  .

        You should check on statistic way,

         but the speed of a connection with GPRS network included  is not the same speed of a "direct"  connection to internet and this may not be avoidable.

        Otherwise it may be necessary a log with another diagnostic tool, but in this case you need to manage this directly with Telit and in any case you should refer to Cosmin