Arduino MQTT Library for SIM800 GSM Modem

Hello,

Below I am sending the link of AT command sequence for TCP connection. Unfortunately the TCP connection turns off 5 seconds later after sending the message over TCP connection.

https://paste.ubuntu.com/p/phWmhpmJvq/

Could you please help us indeed, why this happens? Do you have any suggestion?

Thanks in advance!

To which server you are connecting?
It disconnects if you dont send right connect packet and if there is inactivity.

The server is debian-jessi.
We can easily get connected to our server it is fine but when we send message such as"hello world" or MQTT connection package over TCP, the connection establishes but connection turns off 5 seconds later. The connection between server and device gets disconnected, message we receive “CLOSED” .

what would be the main issue?

In my experience, TCP connection on SIM800 is very unstable. You should try avoiding the use of delay() between commands. Try to capture and interpret the response of the module after each command and immediately send the next command, as the TCP connection seems to be very time sensitive (and generally inpatient). The module is already very slow, so adding delays might be worsening the situation.

Also, if you can avoid using TCP and switch to HTTP, the interface in the SIM800 is much better, as it lets you prepare all the data and send it in one go (thus avoiding those pesky time constraints).

1 Like