Issue establishing a TCP connection using PLS62-W | Telit Cinterion IoT Developer Community
February 4, 2020 - 12:46pm, 5885 views
Hi,
I am currently trying to create a TCP socket to connect my AWS broker. My plan is to once I can succesfully connect to AWS using transparent TCP, is to use the MQTT client in my micrcontroller to publish data.
This is the steps that I have taken to try and create transparent TCP connection:
*Setup internet service profile*
AT+CPIN? +CPIN: READY
OK
AT+CSQ
+CSQ: 4,99
OK
AT+COPS?+COPS: 0,0,"vodafone UK",2
OK
AT+CGREG?+CGREG: 0,1
OK
AT+CGDCONT=1,"IP","wap.vodafone.co.uk"
OK
AT+CGATT=1
OK
AT^SICA=1,1
OK
*Create TCP socket and establish connection*
AT^SISS=1,srvType,"Socket"
OK
AT^SISS=1,conId,1
AT^SISS=1,address,"socktcp://xxxxxxxxxxxx-ats.iot.us-west-2.amazonaws.com:8883;etx;timer=200"
OK
AT^SISO=1
OK
at^sist=1
OK
at^sisi=1^SISI: 1,6,0,8,8,0
OK
at^sist=1 CONNECT
..
NO CARRIER
^SIS: 1,0,48,"Remote peer has closed the connection"
^SISR: 1,2
AT^SISO?^SISO: 0,""
^SISO: 1,"Socket",5,2,0,16,"10.229.118.129:4098","35.155.189.22:8883"
^SISO: 2,""
^SISO: 3,""
^SISO: 4,""
^SISO: 5,""
^SISO: 6,""
^SISO: 7,""
^SISO: 8,""
^SISO: 9,""
OK
AT^SISW=1,10^SISW: 1,10,0
ERROR
^SIS: 1,0,48,"Remote peer has closed the connection"
^SISR: 1,2
My problem is I keep getting the error ^SIS: 1,0,48,"Remote peer has closed the connection" or ^SISE: 1,61,"Fatal: Service has no socket connection".
I am able to succesfully connect to my broker using HTTP and publish data to it so am not sure why I am unable to create TCP connection.
Any guidance would be greatly appreciated.
Thanks
I have realised that the above error message was only being sent after I send a wrongly formatted packet and that it initally occured by accident. Using the original packets that I sent dont result in an error message being forwarded by the broker. Its still very strange that I only receive a response from the broker if an incorrect packet is sent.
Cheers
And how about if you subscribe to a topic? Is there anything coming if there's new message published on the topic?
Regards,
Bartłomiej
Hi,
Unfortunately, I receive nothing if I subscribe to a topic that I published to on AWS client website. I still only receive a response from AWS server if I send an incorrect packet. I have posted a question on AWS forum and awaiting a response.
Also, does the MQTT client I implement on my microcontroller need to have TLS added, or do I just need to add AT command driver to pub/sub ?
Many thanks
Hello,
You can establish a TLS connection with AT commands also. You ounly need to use socktcps instead of socktcp.
Regards,
Bartłomiej
Hi
I have realised that I have been using the wrong port for Aws Mqtt services. Below is a log of the commands that I have sent using the modem.
AT^SISW=1,40^SISW: 1,40,0 // connect packet
OK
^SISW: 1,1
AT^SISR=1,2^SISR: 1,0
OK
AT^SISW=1,27^SISW: 1,27,0 // publish packet
OK
^SISW: 1,1
^SISR: 1,2 ???
at^sisi?^SISI: 1,6,0,67,67,0
OK
AT^SISR=1,1500^SISR: 1,-2
What I am confused about is that is the terminal telling me that there is data received?
OK
Cheers
Hello,
2 in '^SISR: 1,2' URC means end of data i.e. the data transfer has completed and there's no more data to read (1 menas that data is available and can be read).
That's why you get '^SISR: 1,-2' on read attempt - which in this case is a reply to AT^SISR command and '-2' means here end of data also. Value greater than 0 means the number of bytes.
Please see AT^SISR command description - there's '^SISR:' URC and '^SISR:' command reply defined, but the parameters are different.
Anyway it still looks like there's no answer from the server.
Regards,
Bartłomiej
Hi,
Thank you for getting back to me.
So after I configure my internet service profile and setup a socketcps connection , I attempt to send MQTT packets using SISW command. As mentioned previously the broker disconnects after sending a few write commands. To investigate the issue I used the at+ceer command.
at+ceer
+CEER: "SM activation error",133,"Requested service option not subscribed"
This error might be the cause of the issue I am having.
Can you please explain what this error means and what could be the potential cause of it?
Many thanks
Hello,
This error is related to PDP context activation. Please send AT+CEER=0 to reset error reports and then observe if there's something new.
I think that this may be an old error and it is not related to the problem you have now. PDP context must have been activated as you were able to connect to the destination server and send data. The potential error for your current IP session you can check with AT^SISE=<srvProfileId> command.
Regards,
Bartłomiej
Hi Bartłomiej,
After a connection goes up, the modem allows me to send several packets before it disconnects from AWS with an error message. The error messages seems to vary between "^SISE: 2,61,"Fatal: Service has no socket connection" and "+CEER: "SM activation error",133,"Requested service option not subscribed". Usually, it's the former.
To resolve the issues I am having, do I have to encrypt the MQTT packets using the certificates and then send them using "AT^SISW" command?
Many thanks in advance!
Hello,
To establish an encrypted TLS connection you only need to change the prefix from 'socktcp://' to 'socktcps://' and probably choose the appropriate port on which the server expects the secure connections.
The device authentication method required by your IoT hub is probably configurable in your AWS backend. If you have client and server certificates from AWS you should install them on the module and activate certificate verification for secure connections. Then during the TLS handshake the module verifies the server certificate against what is stored on the module and also send the client certificate which is then verified by the server. This is all done automatically out of your control as a part of secure connection establishment.
As for the certificates handling I think that you can find help here: https://iot-developer.thalesgroup.com/showcase/concept-board-connection-...
"^SISE: 2,61,"Fatal: Service has no socket connection" seems to confirm that the server has closed the socket unexpectedly.
As for "+CEER: "SM activation error",133,"Requested service option not subscribed" I don't know why you still get this, maybe there's a problem with PDP context activation from time to time but the connection to server establishment means that PDP must have been activated finally.
So I think that currently you only have problem with the proper communication with the server or TLS session.
Regards,
Bartłomiej