Waiting For Socket Connection...

Started by Jason, January 28, 2019, 10:51:06 AM

Jason

I was working on setting up two new nodes, and got it working okay-ish I thought.   Then a day or so later after the log in screen, I can only get to the "waiting for socket connection page" wether I connect through the internet or directly to the raspberry pi with an eithernet cable.

Without spending too much time thinking about this, does anyone have any idea what is going on and how to fix it?

Important notes:
- I have restarted the pi multiple times, but that didn't fix the problem.
- I have messed around a little with the gateway code months ago and everything has been functional.  For testing  I did revert all my code changes back to the stock gateway app (I think).
- If no one knows what could be causing this, I am planning on backing up the data and then just "reinstalling" the gateway app.

Kylix


Felix

The NGINX server is working. The gateway.js socket server is probably the problem. If you edited code, that might be the cause - ex an event that fired after it was working, and which failed.
As Kylix suggested - check the gateway.sys.log to see what's going on.

Jason

Thanks! I will check the log file tomorrow!

Jason

Ah-ha! Thanks for the tip to look at the log file.  It turns out my database was corrupted.  I was able to fix it by removing all the files in the db.folder and replaced gateway.sys.log with a blank file (for a fresh start, might not have been needed).

Would a cutting power to the raspberry pi without shutting it down have the potential to corrupt the database?

[01-13-19_17:26:37.592] [LOG]       [2] DB-Updates:1
[01-13-19_17:17:33.207] [INFO]   LOADING USER METRICS...
[01-13-19_17:17:33.374] [INFO]   LOADING USER METRICS MODULE [_example.js]
[01-13-19_17:17:33.403] [INFO]   LOADING USER METRICS MODULE [beehiveMetric.js]
/home/pi/gateway/node_modules/nedb/lib/datastore.js:77
    if (err) { throw err; }
               ^

Error: More than 10% of the data file is corrupt, the wrong beforeDeserialization hook may be used. Cautiously refusing to start NeDB to prevent dataloss
    at Persistence.treatRawData (/home/pi/gateway/node_modules/nedb/lib/persistence.js:242:11)


Thanks, Jason

Felix

Quote from: Jason on January 29, 2019, 09:48:09 PM
It turns out my database was corrupted.

Would a cutting power to the raspberry pi without shutting it down have the potential to corrupt the database?
Never seen that message before but interesting to know it can happen.
And yes, cutting power without a proper shutdown can definitely create all kinds of problems including disk and datafile corruption.

It's why I created ATXRaspi and MightyHat ;)
They are devices that control power and can issue a safe shutdown and reboot request to the Pi (from a button, rather than having to log into the Pi console), then when Pi is done shutting down, they cut power completely.