Randomly dropping connection to mysql server, how to continuously force a reconnect?
#1
I'm not sure how to word this for googling, so I haven't been able to find anything on this. But I have one raspberry pi running kodi and another raspberry pi running the library with mysql. It usually works just fine, I can sync my watched status with it and the other kodi devices. But seemingly for no reason, every couple days, it (the kodi I use to watch on my TV) will just drop it's connection to the mysql server and "forget" all watched status for everything on it. If I reboot it, it comes back and everything is right with the world.

My question is, is there a way I can maybe throw something in a cron job every hour that forces the kodi pi to just go out and try to connect and if it fails, re-establish it or something? Like whatever process it is doing on bootup, can I manually do that with a command myself? That seems like it would solve my problem.

Both are on static IPs and from what I can tell neither is going to "sleep". Any ideas? Thanks!
Reply
#2
(2020-08-14, 21:23)MorkZaDork Wrote: But seemingly for no reason, every couple days, it (the kodi I use to watch on my TV) will just drop it's connection to the mysql server and "forget" all watched status for everything on it. If I reboot it, it comes back and everything is right with the world.

I think I read all this somewhere not too long ago. Wasn't it something like 5 hours that a disconnect happened?

Is this about a wifi connection? Some wifi router / client combinations can have their hiccups, it happens with my current access point and a Ubuntu laptop every 15 minutes. (Yeah, I need to find some access point more stable)
Alternatively, you could install Ubuntu Server on a RPI 3/4, and install MySQL or MariaDB, and give that a try.
Reply
#3
(2020-08-15, 10:46)Klojum Wrote:
(2020-08-14, 21:23)MorkZaDork Wrote: But seemingly for no reason, every couple days, it (the kodi I use to watch on my TV) will just drop it's connection to the mysql server and "forget" all watched status for everything on it. If I reboot it, it comes back and everything is right with the world.

I think I read all this somewhere not too long ago. Wasn't it something like 5 hours that a disconnect happened?

Is this about a wifi connection? Some wifi router / client combinations can have their hiccups, it happens with my current access point and a Ubuntu laptop every 15 minutes. (Yeah, I need to find some access point more stable)
Alternatively, you could install Ubuntu Server on a RPI 3/4, and install MySQL or MariaDB, and give that a try.
It is wifi, both the pis are. The TV pi is a 3b+ and the one running mysql is a zero W. I could in theory get an ethernet adapater for the zero but there's no way for me to run a cable to the one on the TV.

That said, I think you gave me an idea. I ran a test with a simple bash script to take the wlan0 down, wait a second, and bring it back up. It actually seemed to work, when it was down, my pi had no watched status, but as soon as it came back up, it all came back. I think I'm just gonna throw this a .sh file and call it with cron every couple hours:
Quote:ifconfig wlan0 down
sleep 20
ifconfig wlan0 up
I made it sleep for 20 seconds so I could verify the watched status disappears then comes back, but that probably won't be great for general use because it might miss a write to the database if it happens to be down when I finish a show. So I'm gonna try it without the sleep and see what happens. Might take a while to verify it works.
Reply

Logout Mark Read Team Forum Stats Members Help
Randomly dropping connection to mysql server, how to continuously force a reconnect?0