Newb Waiting for socket connection..

Started by boroko, November 22, 2022, 01:32:25 PM

boroko

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

boroko

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

boroko

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.

Felix

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.

boroko

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.

boroko

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


Felix

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.

boroko

#7
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

boroko

#8
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.

boroko

#9
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

boroko

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/"

Felix

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

boroko

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.

boroko

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

Felix

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 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?