Forum Members section DIY Ferduino controller Mosquitto 1.5.7 MQTT

Mosquitto 1.5.7 MQTT  [SOLVED]

Ask here about your controller made with pieces purchased in other shops.

Post Number:#1 Post Tue Dec 07, 2021 7:24 pm
Posts: 20
Topics: 4
Solve rating: 0
Joined: Sat Jul 02, 2016 6:39 am
Topics: 4
Age: 47
Gender: Male
National Flag:
Poland
Hi Fernando

I would like to integrate Ferduino controller first with my home MQTT (mosquitto) server on Raspberry Pi and later maybe with my Domoticz.
I use Esp8266 with my diy Ferduino. Connection with your server works fine but if I want to connect to my home MQTT server there is problem.
After making changes in setup.h (new serwer adress) and in Configuration.h (username and apikey) in your software and changing Esp-link "server hostname or IP", Client ID, Username and Password I can connect controller to my home MQTT and receive transmision from controller on topic log/username/password every about 2 minutes. But if I want to send command to controller (topic: username/password/topic/command) usually connection is lost . Logs from MQTT: "socket error on client ID:username"
Funny thing is that if I send command for example 2.0.0.0.K (username/password/topic/command) to controller just after receiving log/username/password massage from controller (max after few seconds only) controller send response date and time. If I want to send command later usually connection is lost and starts again. User, password and readwrite topics are in Mosquitto file password_m so the user is allowed to public and receive topics.
Wifi connection is stable.
The question is: do I have to add/change any parametrers in mosquitto_conf. or other files to be able to send and received messages to and from controller?

Post Number:#2 Post Wed Dec 08, 2021 11:11 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

What you can see on serial monitor?

Looks like ESP-link or Ferduino code is closing the connection instead keep alive.

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#3 Post Wed Dec 08, 2021 5:32 pm
Posts: 20
Topics: 4
Solve rating: 0
Joined: Sat Jul 02, 2016 6:39 am
Topics: 4
Age: 47
Gender: Male
National Flag:
Poland
MQTT disconnected appears if I send command to controller.

"Syncing Arduino and ESP8266...
Synced!
There will be clouds today.
There will be lightning today.
Cloud schedule [0:0, 0:0, 0:0, 0:0].
Cloud duration: 7 minute(s).
Lightning duration: 3 minute(s).
WIFI connected!
MQTT connected!
Command: maciek/xxxxx/topic/command
Free memory: 3874
Free memory: 3874
Free memory: 3874
Free memory: 3874
Free memory: 3874
Free memory: 3874
Free memory: 3874
Free memory: 3874
Free memory: 3874
Free memory: 3874
Free memory: 3874
Free memory: 3874
MQTT disconnected
MQTT connected!
Command: maciek/xxxxx/topic/command
MQTT disconnected
Free memory: 3874
MQTT connected!
Command: maciek/xxxxx/topic/command"

Post Number:#4 Post Thu Dec 09, 2021 11:38 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

For now I have no idea.

Look the debug log on ESP-Link to try find some useful information.

Image


Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#5 Post Thu Dec 09, 2021 6:56 pm
Posts: 20
Topics: 4
Solve rating: 0
Joined: Sat Jul 02, 2016 6:39 am
Topics: 4
Age: 47
Gender: Male
National Flag:
Poland
I have been watching this logs few hours already and as I asked in my first post I think that something is wrong with Mosquitto config.
First part of logs is fine in my opinion:
" 14114> MQTT connectedCb=dfd
 14114> MQTT: Connected Cb=0x00000dfd
 14115> cmdResponse: cmd=3 val=3581 argc=0
 14938> SLIP: start or end len=0 inpkt=1
 14938> SLIP: start or end len=50 inpkt=1
 14939> cmdParsePacket: cmd=12 argc=2 value=0
 14939> cmdExec: Dispatching cmd=MQTT_SUB
 14939> MQTT: MQTTCMD_Subscribe topic=maciek/xxxxx/topic/command, qos=0
 14939> MQTT: Subscribe, topic: "maciek/xxxxx/topic/command"
 14939> MQTT: Send type=SUBSCRIBE id=0001 len=39
 14951> MQTT: Recv type=SUBACK id=0001 len=5; Pend type=SUBSCRIBE id=01
 15190> Wifi check: mode=AP+STA status=5
 15190> Wifi got IP. Going into STA mode..
 15191> bcn 0
 15191> del if1
 15191> pm open,type:2 0
 15191> mode : sta(40:f5:20:2d:9b:7f)
 30244> Wifi check: mode=STA status=5
 47282> HTTP GET /home.html: 200, 65ms, h=15400
...."


All strange things starts when I send command but not always. If I send command just after controller publish topic log/maciek/xxxx controller publish response. But only few seconds.

"707856> MQTT Client: Received topic: maciek/xxxx/topic/command, data: 2,0,0,0,K
707856> MQTT: Data cb=0x00000e0f topic=maciek/xxxx/topic/command2,0,0,0,K len=9
707857> cmdResponse: cmd=3 val=3599 argc=2
707901> SLIP: start or end len=0 inpkt=1
707910> SLIP: start or end len=108 inpkt=1
707910> cmdParsePacket: cmd=11 argc=5 value=0
707910> cmdExec: Dispatching cmd=MQTT_PUB
707910> MQTT: MQTTCMD_Publish topic=maciek/xxxx/topic/response, data_len=39, qos=0, retain=0
707911> MQTT: Publish, topic: "maciek/xxxx/topic/response", length: 76
707911> MQTT: Send type=PUBLISH id=0000 len=76
709754> MQTT: Recv type=PUBLISH id=0000 len=45; Pend type=NULL id=00"


and after next command send:

"771172> MQTT: MQTTCMD_Subscribe topic=maciek/xxxx/topic/command, qos=0
771172> MQTT: Subscribe, topic: "maciek/xxxx/topic/command"
771173> MQTT: Send type=SUBSCRIBE id=000A len=39
771178> MQTT: Recv type=SUBACK id=000A len=5; Pend type=SUBSCRIBE id=0A
773129>
[b][u]773129> MQTT ERROR: Keep-alive timed out[/u][/b]
773129> MQTT: Disconnecting from 89.71.76.194:1883 (0x3fff7a38)
773130> MQTT Client: Disconnected
773130> MQTT: Disconnected cb=0x00000e03
773130> cmdResponse: cmd=3 val=3587 argc=0
773131> MQTT: Disconnect CB, freeing espconn 0x3fff7a38"


Sorry for long post but I also add short log from Mosquitto:

"1639085754: Received PUBLISH from maciek_PC MQTT.fx (d0, q0, r0, m0, 'maciek/xxxxx/topic/command', ... (9 bytes))
1639085754: Sending PUBLISH to maciek_PC MQTT.fx (d0, q0, r0, m0, 'maciek/xxxxx/topic/command', ... (9 bytes))
1639085754: Sending PUBLISH to ID:maciek (d0, q0, r0, m0, 'maciek/xxxxx/topic/command', ... (9 bytes))
1639085754: Received PUBLISH from ID:maciek (d0, q0, r0, m0, 'maciek/xxxxx/topic/response', ... (39 bytes))
1639085754: Sending PUBLISH to maciek_PC MQTT.fx (d0, q0, r0, m0, 'maciek/xxxx/topic/response', ... (39 bytes))
1639085759: Received PUBLISH from maciek_PC MQTT.fx (d0, q0, r0, m0, 'maciek/xxxxx/topic/command', ... (9 bytes))
1639085759: Sending PUBLISH to maciek_PC MQTT.fx (d0, q0, r0, m0, 'maciek/xxxx/topic/command', ... (9 bytes))
1639085759: Sending PUBLISH to ID:maciek (d0, q0, r0, m0, 'maciek/xxxxx/topic/command', ... (9 bytes))
1639085759: [b][u]Socket error on client ID:maciek, disconnecting[/u][/b].
"

Post Number:#6 Post Thu Dec 09, 2021 7:56 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

I think the problem is here:

 MQTT ERROR: Keep-alive timed out


Increase the time in the ESP-link interface.

Image
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#7 Post Fri Dec 10, 2021 7:28 pm
Posts: 20
Topics: 4
Solve rating: 0
Joined: Sat Jul 02, 2016 6:39 am
Topics: 4
Age: 47
Gender: Male
National Flag:
Poland
I have changed Keep Alive Interval (seconds) to 180 or 360 but with no effect.
Than I have changed Client Timeout (seconds) also to 20 sec. but still the same.
Still "Socket error on client ID:maciek, disconnecting" - from Mosquitto log.
I will change esp8266 into ethernet board to be sure if it is esp problem or server problem. :-?

Post Number:#8 Post Mon Dec 13, 2021 1:05 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Socket error on client ID:maciek, disconnecting


Hi!

This error is from Mosquitto log?

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#9 Post Tue Dec 14, 2021 12:55 pm
Posts: 20
Topics: 4
Solve rating: 0
Joined: Sat Jul 02, 2016 6:39 am
Topics: 4
Age: 47
Gender: Male
National Flag:
Poland
Yes. This error comes from Mosqitto log.
In the mean time I change esp8266 into ethernet shield and everything works fine. That means that problem is esp8266 module or there is something wrong in communication between esp8266 and Mosquitto server on Raspberry pi. Raspberry is connected to main home router by ethernet cable. Controller with esp8266 is connected to wifi on second home router. I couldn't connect esp8266 to main's router wifi because they don't want to cooperate. Strange thing because it provides b/g/n wifi.

Post Number:#10 Post Fri Dec 17, 2021 9:18 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

Happy to know you have found the root of the problem.

When possible please show us the integration of your Ferduino controller with your home automation.

For now I"ll close this topic.

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.




Return to DIY Ferduino controller





Who is online

Users viewing this topic: No registered users and 1 guest