1

I am trying to connect to my mosquitto broker on esp32 with GSM using pubsubclient but sometimes it disconnects to broker with detail malformed packet.

2023-08-30T13:43:14: Client client_id disconnected due to malformed packet.

I have this dump at command on device and it display like this :

13:31:08.540 > DATA ACCEPT:0,2
13:31:08.540 > AT+CIPSEND=0,2
13:31:08.568 > 
13:31:08.568 > 
13:31:08.570 >  
13:31:08.604 > DATA ACCEPT:0,2
13:31:08.604 > AT+CIPRXGET=4,0
13:31:08.660 > 
13:31:08.660 > +CIPRXGET: 4,0,0
13:31:08.660 > 
13:31:08.660 > OK
13:31:08.660 > AT+CIPSTATUS=0
13:31:08.755 > 
13:31:08.755 > +CIPSTATUS: 0,0,"TCP","13.228.184.92","80","CONNECTED"
13:31:08.760 > 
13:31:08.760 > OK
13:31:09.762 > AT+CIPRXGET=4,0
13:31:09.780 > 
13:31:09.781 > +CIPRXGET: 1,0
13:31:09.817 > 
13:31:09.818 > +CIPRXGET: 4,0,370
13:31:09.818 > 
13:31:09.818 > OK
13:31:09.818 > AT+CIPSTATUS=0
13:31:09.917 > 
13:31:09.918 > +CIPSTATUS: 0,0,"TCP","BROKER IP","80","REMOTE CLOSING"

I have limited some possibilities that are causing the problem.

  • After failing to connect to broker I try to connect to server using http and it connected without problems.
  • Tried using public broker like hivemq for a short time and it does not have a problem.
  • I have tried to connect to broker using another device (Android, mqttx, etc.) and they run well also.
9
  • 1
    Why do you think connecting via http is meaningful? Is the broker also configured to accept WebSocket connections on port 80?
    – hardillb
    Commented Aug 30, 2023 at 8:48
  • Is there any way you could capture the actual packets on either side? Your log tells us that packets were exchanged, but not their contents. Does it disconnect right away, or does it take some time before it does?
    – jcaron
    Commented Aug 30, 2023 at 16:32
  • @hardillb it just to confirm that there is no problem on the sim module. the connection is stable
    – furqon2710
    Commented Aug 31, 2023 at 3:42
  • Also, what protocol are you actually using? MQTT? HTTP? With or without TLS? The log above shows port 80...
    – jcaron
    Commented Aug 31, 2023 at 12:26
  • 1
    So what is the relevance of the log you provided which apparently deals with a connection on port 80?
    – jcaron
    Commented Sep 1, 2023 at 7:26

0

Browse other questions tagged or ask your own question.