Issue connecting to MQTT broker | Thales IoT Developer Community
May 14, 2020 - 8:28pm, 1885 views
Hi,
I am trying to connect my pls62-w terminal (orange dev kit) to a hiveMQ MQTT broker using SocketTcp. I have written a basic driver for my microcontroller to send AT commands to the terminal using serial communication. I am able to initalise and config the modem to connect to the internet. However, every time I send a connect packet using SocketTcp, I am always presented with the following error.
^SIS: 1,0,48,"Remote peer has closed the connection"
^SISR: 1,2
The following is the commands I send in order to attemp to connect to hivemq broker. I am also using a serilisation MQTT lib by Paho to generate the MQTT packets.
...........................................................................................................................
AT+CPIN?+CPIN: READY
OK
AT+CSQ+CSQ: 99,99
OK
AT+COPS?+COPS: 0,0,"vodafone UK",2
OK
AT+CGDCONT=1,"IP","wap.vodafone.co.uk"OK
AT+CGATT=1OK
AT^SICA=1,1OK
AT^SISX=HostByName,1,"broker.hivemq.com"^SISX: "HostByName", "18.196.144.22"
OK
AT^SISS=1,srvType,"Socket"OK
AT^SISS=1,conId,1OK
AT^SISS=1,"address","socktcp://18.196.144.22:8000;etx;autoconnect=1;connecttimeout=180"OK
AT^SISO=1OK
^SISW: 1,1
AT^sisi=1^SISI: 1,4,0,0,0,0
OK
at^sist=1CONNECT
OK
^SIS: 1,0,48,"Remote peer has closed the connection"
^SISR: 1,2
AT^sisi=1^SISI: 1,6,0,21,21,0
OK
AT^SISC=1OK
If I am missing anything, please let me know.
Many thanks
Kav
Hello,
If the server closes the connection (after you start communication) I think that there may be some problem in the date you send i.e. in what your lib generates. Please also make sure if the address and port is correct. You may try some other socket connection to some socket test server to proove that it is possible to communicate over sockets or some online MQTT client to test communication with the broker.
BTW the parameters "autoconnect=1;connecttimeout=180" are for TCP listener only.
Best regards,
Bartłomiej
Hi,
Thanks for getting back to me.
I have managed to fix the issue with the MQTT packets that I was sending. I am able to connect to HiveMQ broker and publish data with no issues.
However, I am now having issue to connect to my AWS endpoint. I keep getting the error "Fatal: Service has detected an internal error". I have made sure to setup certificates into modem correctly. I know the certificates have been setup and installed correctly, as I can connect and publish to AWS using HTTPS.
If I am missing anything below, please let me know.
AT^SISX=HostByName,1,"******************-west-2.amazonaws.com"^SISX: "HostByName", "2.11.111.110"
OK
AT^SISS=1,srvType,"Socket"OK
AT^SISS=1,conId,1OK
AT^SISS=1,"address","socktcps://2.11.111.110:8883;etx;timer=400;keepidle=2;keepcnt=2;keepintvl=1"OK
AT^SISO=1OK
AT^sisi=1^SISI: 1,3,0,0,0,0
OK
AT^sisi=1^SISI: 1,3,0,0,0,0
OK
^SIS: 1,0,50,"Fatal: Service has detected an internal error"
AT^sisi=1^SISI: 1,6,0,0,0,0
OK
AT^SISC=1OK
Hello,
Please make sure that your https cooection on AWS requires the same authentication type and certificates. Are there any configuration differences related to the secure connection between https and mqtt services on the server? Please check the firmware version with "ATI1" command. Have you also tried without additional parameters or with different values?
Regards,
Bartłomiej
Hi,
This is the firmware version currently installed
ATI1Cinterion
PLS62-W
REVISION 02.000
A-REVISION 01.000.02
I have double checked my AWS account configurations and made sure that the correct certificates are properly installed in the modem.
The modem keeps showing the same error, even when I have removed these specific settings "timer=400;keepidle=2;keepcnt=2;keepintvl=1" and only left "etx" to open a transparent connection.
Not sure how to proceed right now, so any guidance would be appreciated.
Hello,
The error description does not specify precisely what has happened. If the same authentication is required and https connection works while mqtt does not there must be some difference on the server side either in TLS handshake or later.
If you can't catch service state 4 in SISI but only 3 it suggests that the problem might be during TLS handshake. Or maybe the module connects for a while but the server breaks the connection again - there might be differences between MQTT connection to HiveMQ and AWS - maybe some specific requirements for protocol, user or password format etc.
It could be helpful to see TCP trace but you can't do it on the module side.
You might experiment with a different MQTT client like this one: https://iot-developer.thalesgroup.com/showcase/command-mqtt-client , please also see this: https://iot-developer.thalesgroup.com/showcase/concept-board-connection-...
Regards,
Bartłomiej