Username: Password:

Author Topic: MQTTController stop sending massages to nodes after some time that is active  (Read 84 times)

tasosmich

  • Newbie
  • *
  • Posts: 4
    • View Profile
Hello,

i encounter a problem with MQTTController file. As i describe in the subject, MQTTController stop sending messages to action nodes after about an hour that is active. But it continues to receive massages.

If i start it again with the commands

Code: [Select]
cd ~/sensors
sudo ./MQTTController

then it works just fine. It sends and receives massages normally. About an hour later the same happens. 

What do you think is the problem?

Thank you in advance!

tasosmich

  • Newbie
  • *
  • Posts: 4
    • View Profile
Hi, i want to update the information about the problem.

In the MQTTController i deactiveted all the printf commands and now the time that the raspberry can send information to the sensor increased in about one day.

Also i notice that the raspberry stops receiving massages (despite that the sensors is sending) after about 3 days of activity. After that period the CPU utilization is always at 50%. Normally is at 0 - 5% (i have a raspberry pi 3 model B.).  If i try to run MQTTController again nothing happens. The raspberry neither sends or receives massages.

If i reboot the raspberry then all systems works fine. 

If anyone can come up with a solution, please share!

tasosmich

  • Newbie
  • *
  • Posts: 4
    • View Profile
Hello,

i managed to solve that problem. At first sight it seems that some stack got overflowed and in every restart the system worked again.
So through cron commands i set the raspberry pi to restart every day at 5 a.m. and also every half hour i kill the MQTTController process and i start it again.

With that the problem has been fixed.

If you want to do the same:
1) Create a script inside the etc/rc5.d folder with the commands:
Code: [Select]
cd /etc/rc5.d
sudo nano RunMQTT.sh

2) then type inside the new file:
Code: [Select]
#!/bin/bash

cd/
cd home/pi/sensors #this is where you keep the MQTTController file
sudo killall ./MQTTController
sudo sleep 5
sudo ./MQTTController
cd /

3) save the file with ctr+x , press y and then enter.

4) after that you need to make that file executable. Type: 
Code: [Select]
sudo chmod +x RunMQTT.sh
5) Then open a new terminal windows and type
Code: [Select]
sudo crontab -e
6) Scroll at the bottom at the file after the comment and type
Code: [Select]
0 5 * * * sudo rebootthat is to reboot the system every day at 5 a.m.

7) also type:
Code: [Select]
@reboot sh /etc/rc5.d/RunMQTT.shThat command is to start the MQTT file at system start up
You may already have this activated in your rc.local file. Check before you enable that command

8 ) make a new file to keep the logs from the RunMQTT script. In a new terminal type:
Code: [Select]
cd /home/pi/sensors/logs/
sudo nano cronlog
leave the file empty and save it by pressing ctr+x then y and enter.

9) finally type:
Code: [Select]
*/30 * * * * sh /etc/rc5.d/RunMQTT.sh >/home/pi/sensors/logs/cronlog 2>&1this will restart MQTTController file every 30 minutes and keep the logs in the file that we just created.