LowPowerLab Forum

Software support => Pi Gateway => Topic started by: boroko on November 22, 2022, 01:32:25 PM

Title: Newb Waiting for socket connection..
Post by: boroko on November 22, 2022, 01:32:25 PM
Hi All,
Been involved with embedded for a long time, but never with RasPi.  I've had a 4b, a MightyHat, and a couple of Moteinos floating around and finally decided to make myself understand this ecosystem. The programming on the MightyHat and the RasPi seem to have loaded properly.  The RasPi was loaded with the setup script.  I also formatted the SD and did it again from scratch in case I boffed it up getting the MightyHat sorted out (lots of power cycles without proper sequencing).
I'm getting a Moteino with a WeatherShield reporting back, as I can watch it on the MightyHat serial terminal, so that much of it is working.  When I try to get the webGUI to respond, I get a splash screen, I log in, and get a "Waiting for socket connection.."  The splash tells me that I'm at least part way in.  I can log into the Pi from the command line, so I don't think that is the issue (even though I don't know my way around there yet).   
I have been reading for 2 days and not finding a path.  Either the forum advice is ancient and covers many versions ago, or I haven't figured out what to look for yet.  I did see a thread about a corrupted database, and went looking for it.  In /var/log/* I don't see anything that I can identify as the db log to clear, if that's even the issue. 

Now I am very aware that this is an older project, and doesn't have the activity that it used to, but I have a perfect use for it's functionality now, and I'd love to master it a bit more.  If anyone could point me in the right direction on where to learn more, I would greatly appreciate it. In the mean time, I'll keep reading and improving my grasp, so I can speak more intelligently and maybe figure out how to read the logs to get hints without a desktop.
Thanks,
bo
Title: Re: Newb Waiting for socket connection..
Post by: boroko on November 22, 2022, 05:02:35 PM
OK, a little progress.  Still not sure what I'm looking at, but found the webserver.error.log.  The most prevalent entrys were:
...[error] 526#526: *11 open() "/usr/share/nginx/html/50x.html" failed (2: No such file or directory), client 192.168.0.68, server: gateway, request:"GET /socket.io/socket.io.js HTTP/1.1, upstream: "http://127.0.0.1:8080/.io.socket.io.js", host: "192.168.0.90" referrer: "192.169.0.90/"

and another:
...[error] 524#524: *1 connect()  failed (111: Connection Refused) while connecting to upstream, client 192.168.0.68, server: gateway, request: "Get /socket.io/socket.io.js HTTP/1.1, upstream: "http://127.0.0.1:8080/.io.socket.io.js", host: "192.168.0.90" referrer: "192.169.0.90/"

Don't completely understand it, but if the nnn#nnn is an error code, most were 526#526, followed by 524#524, and a few 525#525. 
Does that give any insight?

Thanks
bo
Title: Re: Newb Waiting for socket connection..
Post by: boroko on November 22, 2022, 05:24:01 PM
Also found my way to /home/pi/gateway/data/db and saw that gateway.db and gateway_nonmatches.db to be 0 sized, so I'm guessing that corrupted databases are not the issue.
Title: Re: Newb Waiting for socket connection..
Post by: Felix on November 23, 2022, 04:59:01 PM
Somehow this looks like something went wrong with the install. Did you see any errors during setup?
I would try again and make sure to pick the latest HEAD rather than the latest release. That gives you the latest available files.
You don't need the MHat or anything on the Pi for a successful install, and having it attached won't hurt either.
Title: Re: Newb Waiting for socket connection..
Post by: boroko on November 23, 2022, 05:40:54 PM
Felix,

Thanks for the reply.  I have been working through just looking at the different parts of the code to get some idea of how it works.  Linux is pretty foreign to me and I need to just see how it goes together.   I will go through another reload, and try the latest and see how it goes.
Title: Re: Newb Waiting for socket connection..
Post by: boroko on November 26, 2022, 07:02:01 AM
Learning things but seem to be no closer to getting it to open a socket. 

Fresh loads of both the latest or the stable version seem to make no difference in the results.  It makes the initial connection and requests the password, then it gets stuck waiting. I'll keep digging and learning more, but if anyone has a lightbulb moment, I'd be grateful for where to look for clues.

Thanks
bo

Title: Re: Newb Waiting for socket connection..
Post by: Felix on November 26, 2022, 11:53:39 AM
Hit F12 to bring up developer tools in the browser and watch for page/javascript errors as the page loads.
Otherwise go back and look in the web server errors, if it's the same error as before.
Title: Re: Newb Waiting for socket connection..
Post by: boroko on November 27, 2022, 07:58:30 PM
Felix,
Sorry I'm not really up to speed on this, but I am trying... :-)

Here is what I get on the webpage from the developer console:

GEThttps://192.168.0.88/socket.io/socket.io.js
[HTTP/1.1 404 Not Found 75ms]

Loading failed for the <script> with source
Title: Re: Newb Waiting for socket connection..
Post by: boroko on November 27, 2022, 08:28:10 PM
Wow, the complete post is getting mutilated...  lets try again, in pieces...

Browsing on Win10 with Firefox, and tried Edge with no change.
The images on the Pi are both the full and the lite version loaded fresh with the Pi Imager.
The Gateway was loaded with the script:
cd /home/pi
sudo wget https://raw.githubusercontent.com/LowPowerLab/RaspberryPi-Gateway/master/.setup/gatewaysetup.sh
sudo bash gatewaysetup.sh && sudo rm gatewaysetup.sh

Accessing 192.168.0.88 brings up the LowPowerLab splash screen and gives a "Waiting for socket connection" message.
Title: Re: Newb Waiting for socket connection..
Post by: boroko on November 27, 2022, 08:41:51 PM
The Developers Console on the browser (F12) is showing:
GET http://192.168.0.88/socket.io/socket.io.js
Loading failed for the <script> with source "https://192.168.0.88.socket.io/socket.io.js"
Layout was forced before the page fully loaded. 
! Uncaught ReferenceError: io is not defined
   <anonymous> https://192.168.0.88/:784
Title: Re: Newb Waiting for socket connection..
Post by: boroko on November 27, 2022, 08:46:56 PM
The error log has this pattern:
2022/11/27 18:37:41 [error] 588#588: *19 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.68, server: gateway, request: "GET /socket.io/socket.io.js HTTP/1.1", upstream: "http://127.0.0.1:8080/socket.io/socket.io.js", host: "192.168.0.88", referrer: "https://192.168.0.88/"
2022/11/27 18:37:41 [error] 588#588: *19 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.68, server: gateway, request: "GET /socket.io/socket.io.js HTTP/1.1", upstream: "http://[::1]:8080/socket.io/socket.io.js", host: "192.168.0.88", referrer: "https://192.168.0.88/"
2022/11/27 18:37:41 [error] 588#588: *19 open() "/usr/share/nginx/html/50x.html" failed (2: No such file or directory), client: 192.168.0.68, server: gateway, request: "GET /socket.io/socket.io.js HTTP/1.1", upstream: "http://[::1]:8080/socket.io/socket.io.js", host: "192.168.0.88", referrer: "https://192.168.0.88/"
Title: Re: Newb Waiting for socket connection..
Post by: Felix on November 27, 2022, 09:23:43 PM
So it looks like socket.io cannot be loaded, was there no error during setup?

Do you have this file on the server?
/home/pi/gateway/www/socket.io/socket.io.js
Title: Re: Newb Waiting for socket connection..
Post by: boroko on November 27, 2022, 09:37:51 PM
I have seen no error, but I could have missed it. 
Looking at it on WinSCP, I can go right to it, so it looks like it's there.
Title: Re: Newb Waiting for socket connection..
Post by: boroko on November 30, 2022, 10:39:12 PM
This has taken me a little while to learn how to get a look at the boot log, but I seem to be getting closer.

I found this sequence 13 times:

Started Moteino Gateway Serivce.
gateway.service: Failed to determine user credentials: No such process
gateway.service: Failed to step USER spawning /bin/sh: No such process
gateway.service: Main process exited, code=exited, status=217/USER
gateway.service: Failed with result 'exit-code'.
gateway.service: Scheduled restart job, restart counter is at 3
Stopped Moteino Gateway Service.


That looks suspiciously like it might me the problem.  Now I have to figure out what it means.
bo
Title: Re: Newb Waiting for socket connection..
Post by: Felix on December 01, 2022, 10:37:15 AM
Yeah so the gateway service is not even running.
I haven't tried an install lately but I wonder if this is because of this change (https://arstechnica.com/gadgets/2022/04/raspberry-pi-os-axes-longstanding-default-user-account-in-the-name-of-security/) and pi no longer being default username.

If that's the case then maybe all the install files need to be revisited.

BUT I should ask - what username did you choose during the OS install?
Title: Re: Newb Waiting for socket connection..
Post by: boroko on December 01, 2022, 02:39:23 PM
I changed it before the install and having these issues.
Should I do a fresh install and use the defaults and see if it works?
Title: Re: Newb Waiting for socket connection..
Post by: Felix on December 02, 2022, 09:21:17 AM
The setup uses the pi default user. Try that and let me know if that solves it. You can of course (and should!) change the default password.
Title: Re: Newb Waiting for socket connection..
Post by: boroko on December 02, 2022, 12:54:24 PM
Well, I think we have a winner!
Started from scratch with a clean install using default logins and the gateway is up and running.   
I did have to start the gateway, so I'll have to change the settings to auto-start.  Also, I need to change the default login to something not so common.  Other than that, I think we have it. 

Appreciate you walking me through this.
bo
Title: Re: Newb Waiting for socket connection..
Post by: Felix on December 02, 2022, 01:00:17 PM
Ok, thanks for the follow up.
I think that puts a medium priority work item on the list ;-)
Title: Re: Newb Waiting for socket connection..
Post by: boroko on December 02, 2022, 03:03:26 PM
Wasn't trying to add to your workload.  Figured it was the result of excessive head-gap on my end.