Unable to connect to webserver

Supporting Linux and other Unixes
Mastiff
Phidgetly
Posts: 24
Joined: Fri Sep 11, 2020 9:20 am

Unable to connect to webserver

Post by Mastiff »

I am pretty sure I have the webserver running on port 8081, as ss shows:

Code: Select all

pi@MadMax2:~ $ sudo ss -ltnp
State     Recv-Q    Send-Q       Local Address:Port        Peer Address:Port    Process                                                                         
LISTEN    0         4096               0.0.0.0:61208            0.0.0.0:*        users:(("docker-proxy",pid=1496,fd=7))                                         
LISTEN    0         4096               0.0.0.0:5661             0.0.0.0:*        users:(("phidget22networ",pid=939,fd=14))                                      
LISTEN    0         128                0.0.0.0:22               0.0.0.0:*        users:(("sshd",pid=773,fd=3))                                                  
LISTEN    0         5                  0.0.0.0:5900             0.0.0.0:*        users:(("vncserver-x11-c",pid=767,fd=12))                                      
LISTEN    0         128              127.0.0.1:631              0.0.0.0:*        users:(("cupsd",pid=754,fd=7))                                                 
LISTEN    0         100                0.0.0.0:1883             0.0.0.0:*        users:(("mosquitto",pid=763,fd=5))                                             
LISTEN    0         511                0.0.0.0:1880             0.0.0.0:*        users:(("node-red",pid=2097,fd=19))                                            
LISTEN    0         4096               0.0.0.0:8081             0.0.0.0:*        users:(("phidget22networ",pid=939,fd=13)) 
This is on the Pi that is 192.168.3.2 But when I try to connect from 192.168.3.1, it does not work. The 0.0.0.0:8081 should mean that it can be connected to from anywhere. Running the check in the documentation should also in my understanding show that I have it all up and running, and it should be possible to contact from the other Pi:

Code: Select all

pi@MadMax2:~ $ phidget22admin -s
Phidget22 Server   MadMax2                        MadMax2:5661             192.168.3.2   
Phidget22 Web Server listener MadMax2 Phidget22 WWW Server   MadMax2 Phidget22 WWW Server:8081 172.18.0.1    
Phidget22 Web Server listener MadMax2 Phidget22 WWW Server   MadMax2 Phidget22 WWW Server:8081 127.0.0.1     
Phidget22 Web Server listener MadMax2 Phidget22 WWW Server   MadMax2 Phidget22 WWW Server:8081 192.168.3.2   
Phidget22 Web Server listener MadMax2 Phidget22 WWW Server   MadMax2 Phidget22 WWW Server:8081 172.20.0.1    
Phidget22 Web Server listener MadMax2 Phidget22 WWW Server   MadMax2 Phidget22 WWW Server:8081 172.17.0.1    
I am unable to check on the Pi running Phidgets because it is a Pi 4 1 gig, which can't run a web browser.

This is what I get when I try to connect:
Phidgets server no contact.jpg
The log says this, I am pretty sure it is important, but I have no idea what it means:

Code: Select all

2025-10-24T14:22:37.618 <ERROR> phidget22 : 
	******************************  Logging Enabled  ******************************
	* Phidget22 - Version 1.23 - Built Oct  6 2025 15:07:24                       *
	* Release 1.23 - Linux (ARM64)                                                *
	*******************************************************************************
2025-10-24T14:23:19.749 <ERROR> phidget22 : 
	******************************  Logging Enabled  ******************************
	* Phidget22 - Version 1.23 - Built Oct  6 2025 15:07:24                       *
	* Release 1.23 - Linux (ARM64)                                                *
	*******************************************************************************
2025-10-24T14:23:19.763 <ERROR> phidget22net[startIPhidgetServer()] : failed to open server socket
	mos_netops-unix.c+200 mos_netop_tcp_openserversocket() : (IO Failure) failed to bind socket: Address already in use
2025-10-24T14:23:19.763 <ERROR> phidget22net[startServer()] : failed to start server
2025-10-24T14:23:20.763 <ERROR> netsrv[runPhidgetNetworkServer()] : failed to start phidget server
2025-10-24T14:29:02.118 <ERROR> phidget22 : 
	******************************  Logging Enabled  ******************************
	* Phidget22 - Version 1.23 - Built Oct  6 2025 15:07:24                       *
	* Release 1.23 - Linux (ARM64)                                                *
	*******************************************************************************
2025-10-24T14:41:25.053 <ERROR> www[handleWWWClient()] : failed to read HTTP request
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('O')
2025-10-24T14:41:25.058 <ERROR> phidget22net[runClientConnection()] : 'webserver-1' failed for client _www://192.168.3.1:46390
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('O')
2025-10-24T14:41:25.069 <ERROR> www[handleWWWClient()] : failed to read HTTP request
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.069 <ERROR> phidget22net[runClientConnection()] : 'webserver-2' failed for client _www://192.168.3.1:46394
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.076 <ERROR> www[handleWWWClient()] : failed to read HTTP request
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.076 <ERROR> phidget22net[runClientConnection()] : 'webserver-3' failed for client _www://192.168.3.1:46400
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.083 <ERROR> www[handleWWWClient()] : failed to read HTTP request
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.084 <ERROR> phidget22net[runClientConnection()] : 'webserver-4' failed for client _www://192.168.3.1:46402
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.092 <ERROR> www[handleWWWClient()] : failed to read HTTP request
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.092 <ERROR> phidget22net[runClientConnection()] : 'webserver-5' failed for client _www://192.168.3.1:46414
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.098 <ERROR> www[handleWWWClient()] : failed to read HTTP request
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.098 <ERROR> phidget22net[runClientConnection()] : 'webserver-6' failed for client _www://192.168.3.1:46416
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.112 <ERROR> www[handleWWWClient()] : failed to read HTTP request
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.112 <ERROR> phidget22net[runClientConnection()] : 'webserver-7' failed for client _www://192.168.3.1:46430
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.118 <ERROR> www[handleWWWClient()] : failed to read HTTP request
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.118 <ERROR> phidget22net[runClientConnection()] : 'webserver-8' failed for client _www://192.168.3.1:46438
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.128 <ERROR> www[handleWWWClient()] : failed to read HTTP request
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.128 <ERROR> phidget22net[runClientConnection()] : 'webserver-9' failed for client _www://192.168.3.1:46446
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.134 <ERROR> www[handleWWWClient()] : failed to read HTTP request
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
2025-10-24T14:41:25.134 <ERROR> phidget22net[runClientConnection()] : 'webserver-10' failed for client _www://192.168.3.1:46462
	webserver.c+203 readreq() : (Invalid) failed to scan request line ('~')
I had the same problem on a Pi 3 back in 2020, but I got around it by using another method. viewtopic.php?t=10059

Now I would really like to get the server working. I have installed everything again, only kept the scripts I had for it. Does anybody have any idea to something I haven't tried?
You do not have the required permissions to view the files attached to this post.
User avatar
Patrick
Lead Developer
Posts: 688
Joined: Mon Jun 20, 2005 8:46 am
Location: Calgary

Re: Unable to connect to webserver

Post by Patrick »

The built-in webserver is getting garbage bytes from somewhere. I would try changing the ports and see if that helps. Also, make sure that the Pi doesn't have any firewall rules blocking incoming connections.

Did you install the phidget network server from source or from the package repo? If from source, you need to make sure you set up the docroot, mimetypes, and log folders properly.

This is all configured from the phidget22networkserver.pc file - probably installed in /etc/phidgets

-Patrick
Mastiff
Phidgetly
Posts: 24
Joined: Fri Sep 11, 2020 9:20 am

Re: Unable to connect to webserver

Post by Mastiff »

Thanks for the quick answer! I first tried 8080 and then 8081, by changing that .pc file. Should I try another port far from them? I have not installed any firewalls, I don't think Raspberry Pi OS comes with one out of the box. Also, I installed the Phidgets stuff from the package, I don't build anything if I can avoid it. I'm too much of a Windows guy for that. :mrgreen:
User avatar
Patrick
Lead Developer
Posts: 688
Joined: Mon Jun 20, 2005 8:46 am
Location: Calgary

Re: Unable to connect to webserver

Post by Patrick »

Hi,

Have you install the package phidget22wwwjs? This installs the javascript control panel and library into the default docroot for the Phidgets network server webserver.

-Patrick
Mastiff
Phidgetly
Posts: 24
Joined: Fri Sep 11, 2020 9:20 am

Re: Unable to connect to webserver

Post by Mastiff »

Bingo, that was it, thanks! I was hoping that I could see in the web interface when I turned off and on outputs from my 24/7 running python script, but that did not work. At least the mystery was solved! After I sent the on command from the script, I get this when I double click the output, even if I have sent an off command afterwords:

Code: Select all

Unable to open Phidget: Local device: <1012 (PhidgetInterfaceKit 0/16/16) v601 S/N:15593> open failed because device is in use. Check that the Phidget is not already open in another program, such as the Phidget Control Panel, or another program you are developing.
Btw is it possible to run a script that shows the state of outputs while the other script is not sending commands? I can't get to the board to look at the LED or the relay to check if it is firing.