Issue establishing a TCP connection using PLS62-W | Telit Cinterion IoT Developer Community
February 4, 2020 - 12:46pm, 5431 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
Hello,
As SISO returned OK it seems that the connection was established. Have you also succeeded with a Java MQTT client (for instance from our Knowledge Base)?
How soon the server resets the connection? Was your application able to exchange any data?
Maybe the server expects something else than it gets from your MQTT client application. For now it looks more like the problem on MQTT protocol level.
Regards,
Bartłomiej
Hi Bartłomiej,
Thank you for getting back to me. I was able to succesfully connect/pub/sub to AWS using JAVA MQTT client. However, my project requires that I have the MQTT client on my micrcontroller.
You're correct, I am able to see in AWS iot dashboard the number of connections made. Once a connection is established, I try to send an MQTT connect packet using the "AT^SISW" command. However, I'm always met with the following error:
AT^SISO=1OK
^SISW: 1,1
AT^SISW=1,2^SISW: 1,2,0
ERROR
^SIS: 1,0,48,"Remote peer has closed the connection"
^SISR: 1,2
I am struggling to understand how to use the AT^SISW command to send data packets to the AWS broker. Can you please provide an example on use cases as I was not able to find any in the AT command set datasheet?
Many thanks
Abdi
Hello,
I can see in your previous log that you switch to transparent mode. In that mode you don't need to use any AT commands to send data. You can just send and receive the pure data. AT^SISW and AT^SISR commands are necessary in non-transparent modes only. There are some examples in AT commands specification document - please see 'Examples of how to Configure and Use Internet Service Profiles'. Please also see here: https://iot-developer.thalesgroup.com/knowledge-base?title=internet%20se...
Regards,
Bartłomiej
Hello Bartłomiej,
Thank you for getting back to me so soon.
Can you please just clarify on what you mean by "send and receive the pure data"?
From that AT command datasheet I do understand that the command "AT^SIST" will have to be used to send data but just unclear on how.
Can you also please enlighten me with the steps required to send/receive data using the transparent mode?
Many thanks
Hello,
The SIST command just switches the interface over to the transparent mode. In that mode you can't execute any AT commands until you switch back to AT commands mode. In transparent mode you have the direct access to the socket connection. Everything that you send on the interface will be forwarded to the remote party. And every data sent by the remote party will be received on the interface.
In AT commands mode you need to send AT^SISW command with parameters, then you send the exact amount of data and the command returns. After that you cans send another command to send or read data. In transparent mode you just send data. And everything that is sent back by the server also appears on your interface.
Regards,
Bartłomiej
Hi,
Thanks for your swift reply.
My current problem is that after I establish a connection using AT^SISO, I can not send data to AWS as I always have "remote peer closed connection" error.
AT^SISS?^SISS: 0,"srvType",""
^SISS: 1,"srvType","Socket"
^SISS: 1,"conId","1"
^SISS: 1,"address","socktcp://xxxxxxxxxx-ats.iot.us-west-2.amazonaws.com:8883"
^SISS: 1,"tcpMR","10"
^SISS: 1,"tcpOT","6000"
^SISS: 2,"srvType",""
^SISS: 3,"srvType",""
^SISS: 4,"srvType",""
^SISS: 5,"srvType",""
^SISS: 6,"srvType",""
^SISS: 7,"srvType",""
^SISS: 8,"srvType",""
^SISS: 9,"srvType",""
OK
AT^SISO=1OK
AT^SISO=1+CME ERROR: operation temporary not allowed
AT^sisi=1^SISI: 1,4,0,0,0,0
OK
AT^SISW=1,10^SISW: 1,10,0
OK
AT^SISE=1^SISE: 1,48,"Remote peer has closed the connection"
OK
AT^sisi=1^SISI: 1,6,0,10,10,0
OK
As you can see, the modem does not give me the chance to send any data.
My goal is to publish data to AWS using the TCP/IP stack & MQTT. As I am unable to send data to the server, I can not send MQTT ACK & Ping packets.
Is there anything that I am missing?
Any guidance would be greatly appreciated.
Hello,
You are connection with an unencrypted socket connection. Is this available on the cloud? Maybe you should use the secure TLS connection.
Please compare with the Java MIDlet if you connect in the same way, with same credentials etc.
If MIDlet was able to connect there must be a difference somewhre. If the conneciton is established in the same way maybe your MQTT implementation sends something else that the server expects.
Regards,
Bartłomiej
Hi,
I am now able to establish a connection AWS using non transparent tcp. Using the AT^sisw command I sent several MQTT packets as a test to see if that if I can publish any data to a topic. After sending the connect MQTT packet I did not receive a ACK packet back, even though I can see that I made a successful connection on AWS dashboard. I also sent several publish & subscibe MQTT packets. Even though AWS dashboard showed that there was data publications & and subscriptions were happening, I was not able to see any reply from the AWS broker. I tried using the AT^SISR to read any data being received but with no luck.
Can you please tell me how to view any packets received from AWS broker using AT commands? I only found the command AT^SISI useful which notified me whether a connection was up and whether any packets were sent/received.
Below is a snippet of the commands I sent to the modem:
AT^SISS=1,srvType,"Socket"OK
AT^SISS=1,conId,1OK
AT^SISS=1,"address","socktcps://xxxxxxx-ats.iot.us-west-2.amazonaws.com:8443"OK
AT^SISO=1OK
AT^SISI=1^SISI: 1,4,0,0,0,0
OK
AT^SISW=1,60^SISW: 1,60,0
101A000E782D616D7A6E2D6D7174742D63610402003C0006414243444546 // mqtt connect packet
OK
AT^SISW=1,34^SISW: 1,34,0
300F000474726F6E68656C6C6F72617669 // pub packet
OK
AT^SISI=1^SISI: 1,4,0,94,94,0
OK
AT^SISI=1^SISI: 1,4,0,94,94,0
OK
AT^SISW=1,34^SISW: 1,34,0
330F000474726F6E68656C6C6F41424469 // PUB packet
OK
AT^SISW=1,34^SISW: 1,34,0
330F000474726F6E68656C6C6F41424469 // Pub packet
OK
AT^SISW=1,22^SISW: 1,22,0
82090001000474726F6E00 // SUB to tron
OK
Any guidance would be greatly appreciated.
Cheers
Hello,
So now the server does not disconnect and allows to send data.
It seems that it might be some specifics of MQTT implementation on AWS - maybe it's worth asking on some AWS forum.
As for reading your app may receive URCs when there's data to read - please check if you get this reply (it should be enabled by default):
at^scfg=tcp/withurcs
^SCFG: "Tcp/WithURCs","on"
OK
But even if it's not you should be able to read server reply with AT^SISR command (for instance AT^SISR=1,1500) if there's anything to read.
Unfortunately you're not able to trace TCP packets on the module.
Regards,
Bartłomiej
Hi,
I think youre right, there must be a formatting issue with the packets I have tried to send.
After sending this command "AT^SISR=1,1500" , I recieved this error:
AT^SISR=1,1500^SISR: 1,369
HTTP/1.1 400 Bad Request
content-type: application/json
content-length: 96
date: Mon, 10 Feb 2020 13:13:28 GMT
x-amzn-RequestId: cfbfec45-7c76-c48b-1bfd-2b829b7ae8a4
connection: keep-alive
x-amzn-ErrorType: InvalidRequestException:
access-control-allow-origin: *
{"message":"text is empty (possibly HTTP/0.9)","traceId":"cfbfec45-7c76-c48b-1bfd-2b829b7ae8a4"}
Many thanks
Pages