Page 1 of 1

Network server requires authentication

Posted: Thu Jul 20, 2023 2:04 am
by Desmodue
OS PopOS! (Ubuntu)

I have installed libphidget22 using the install script(Non-Root).
Have added the additional packages.

libphidget22-dev
libphidget22extra
phidget22networkserver
libphidget22java
phidget22admin
phidget22wwwjs

No issues, started up phidget22networkserver.

sudo phidget22networkserver -v
Phidget22NetworkServer 1.1
2023-07-20T09:00:03.000 <Info> netsrv[main()] : Phidget22NetworkServer 1.1

I can see the web server and network server are listening

phidget22 463872 root 13u IPv4 1463184 0t0 TCP *:8080 (LISTEN)
phidget22 463872 root 15u IPv4 1470973 0t0 TCP *:5661 (LISTEN)

Using Chrome or Firefox navigating to 127.0.0.1:8080 the page loads but I get a Password prompt modal.

Checked /etc/phidgets/phidget22networkserver.pc

There is no auth present, tried adding a server auth password but it this password does not work.

Code: Select all

phidget {
        enabled: true
        logging {
                level: debug
                file: '/var/log/phidget22networkserver.log'
        }
        network {
                ipv4 {
                        port: 5661
                }
                publish {
                        enabled: true
                }
        }
        feature {
                control {
                        enabled: true
                }
                dictionary {
                        enabled: true
                        directory: '/etc/phidgets/dictionary.d'
                }
        }
        www {
                enabled: true
                docroot: '/var/phidgets/www'
                mimetypes: '/etc/phidgets/mimetypes.kv'
                logging {
                        level: debug
                        accesslog: '/var/log/phidget22access.log'
                }
                network {
                        ipv4 {
                                port: 8080
                        }
                        publish {
                                enabled: true
                        }
                }
                phidgets {
                        enabled: true
                }
        }
}
Added auth

Code: Select all

phidget {
        enabled: true
        auth    {
                password: 'ABCD'
        }
        logging {
                level: debug
                file: '/var/log/phidget22networkserver.log'
        }
        network {
                ipv4 {
                        port: 5661
                }
                publish {
                        enabled: true
                }
        }
        feature {
                control {
                        enabled: true
                }
                dictionary {
                        enabled: true
                        directory: '/etc/phidgets/dictionary.d'
                }
        }
        www {
                enabled: true
                docroot: '/var/phidgets/www'
                mimetypes: '/etc/phidgets/mimetypes.kv'
                logging {
                        level: debug
                        accesslog: '/var/log/phidget22access.log'
                }
                network {
                        ipv4 {
                                port: 8080
                        }
                        publish {
                                enabled: true
                        }
                }
                phidgets {
                        enabled: true
                }
        }
}
Still cannot login.
Have tried removing all packages and deleting folders. reboot and re install. Still get the password prompt !

phidget22networkserver.log

****************************** Logging Enabled ******************************
* Phidget22 - Version 1.16 - Built Jul 6 2023 22:39:42 *
* Release 1.16 - Linux (64-bit) *
*******************************************************************************
2023-07-19T16:18:39.000 <Info> phidget22usb[PhidgetUSBScanDevices()] : Initializing libusb
2023-07-19T16:18:39.000 <Info> phidget22[deviceAttach()] : (Attach) Dictionary (Dictionary) v100 S/N:2 Label:Phidget22 Control
2023-07-19T16:18:39.000 <Info> phidget22net[setAllowClients()] : Client network connections allowed by default
2023-07-19T16:18:39.000 <Info> phidget22net[PhidgetNet_start()] : Starting Networking
2023-07-19T16:18:39.000 <Info> phidget22usb[PhidgetUSBScanDevices()] : New Phidget found in PhidgetUSBBuildList: 1/6
2023-07-19T16:18:40.000 <Info> phidget22[deviceAttach()] : (Attach) 1017 (PhidgetInterfaceKit 0/0/8) v100 S/N:313651
2023-07-19T16:18:40.000 <Info> phidget22net[startServer()] : Published '_phidget22server._tcp' on port 5661 for discovery
2023-07-19T16:18:40.000 <Info> netsrv[startPhidgetServer()] : Started Phidget Server ellie 127.0.0.1:5661
2023-07-19T16:18:40.000 <Info> www[startWebServer()] : Phidget22 Web Server Starting
2023-07-19T16:18:40.000 <Info> www[startWebServer()] : Started Phidget WWW Server ellie Phidget22 WWW Server 0.0.0.0:8080
2023-07-19T16:18:57.000 <Info> www[handleWWWClient()] : updating 127.0.0.1:46602 to device connection
2023-07-19T16:18:57.000 <ERROR> www[handleWWWClient()] : failed to handle phidgets websocket connection
server.c+632 handleDeviceClient() : (Access Denied) failed to start server connection
network.c+1292 startServerConnection() : (Access Denied) failed to authenticate client
2023-07-19T16:18:58.000 <Info> www[handleWWWClient()] : updating 127.0.0.1:43580 to device connection
2023-07-19T16:18:58.000 <ERROR> www[handleWWWClient()] : failed to handle phidgets websocket connection
server.c+632 handleDeviceClient() : (Access Denied) failed to start server connection

I'm now out of ideas....

Help appreciated.

Re: Network server requires authentication

Posted: Fri Jul 21, 2023 8:40 am
by Desmodue
Well, after some purging and cleaning and re installing I have managed to get it working...

Removed any file\folder with phidget in its name.
Purged any phidget packages
cleaned the apt repository

I did find some phidget21 libraries from some time ago.

Thought I'd try a build from source, this threw up a number of errors.

Couldn't find the libphidget22extra library, even though /usr/local/lib was in the path and the file was present.
Added LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib to my env vars, this fixed that problem.
All built and installed but no web page. Then realised I didn't have the source to build phidget22wwwjs

Installed it via apt, still not working.
server wouldn't start, access denied errors for /var/log

Changed /etc/phidgets/phidget22networkserver.pc accesslog path to a user path.
Still an error, removed the server logging directive, still an error.
Added file: user/path/logfile.log to the logging directive

Server started, still no webpage.

Decided to try the script non-root install again.

Noticed that during the apt update there was an error

arch i386 is not available in source https://www.phidgets.com/debian jammy main

Edited /etc/apt/sources.list.d/phidgets.list to specify the architecture

deb [arch=amd64] https://www.phidgets.com/debian jammy main

apt update showed no errors

Installed all the packages, no issues.

Web server works perfectly, no auth popup, can control a phidget outputs.

Javascript code can access the phidget and control the outputs.

I'm not 100% sure if it was a combination of issues or just the arch=amd64 that fixed it.

Hope that helps someone......

Re: Network server requires authentication

Posted: Tue Aug 29, 2023 2:58 pm
by nsmaree
Hi. Thanks for posting this problem. I am having exactly the same issue: I get asked for a password on the server page and nothing works to bypass it. Brian from Phidget's support also suggested adding Auth to the phidget22networkserver.pc file, but not even he could fix it.

I have since tried your instructions:
1) removed all apt-get installations
2) Added deb [arch=amd64] https://www.phidgets.com/debian jammy main to /etc/apt/sources.list.d/phidgets.list
3) Re-installed using the script:
curl -fsSL https://www.phidgets.com/downloads/setup_linux | sudo -E bash - &&\
sudo apt-get install -y libphidget22

4) Installed all additional libraries with sudo apt-get install libphidget22-dev libphidget22extra phidget22networkserver libphidget22java phidget22admin phidget22wwwjs

Here is what I get when I run the above:

Code: Select all

$ curl -fsSL https://www.phidgets.com/downloads/setup_linux | sudo -E bash - &&sudo apt-get install -y libphidget22

## Installing the Phidgets Inc. repo...


## Populating apt-get cache...

+ apt-get update
Hit:1 httpzaarchiveubuntucom/ubuntu jammy InRelease
Hit:2 httpzaarchiveubuntucom/ubuntu jammy-updates InRelease              
Hit:3 httpzaarchiveubuntucom/ubuntu jammy-backports InRelease            
Hit:4 httpsecurityubuntucom/ubuntu jammy-security InRelease               
Hit:5 https://www.phidgets.com/debian jammy InRelease                     
Reading package lists... Done

## Confirming "jammy" is supported...

+ wget -qO /dev/null -o /dev/null 'https://www.phidgets.com/debian/dists/jammy/Release'
+ wget -qO /dev/null -o /dev/null 'https://www.phidgets.com/debian/dists/jammy/main/binary-amd64/Release'

## Adding the Phidgets Inc. signing key to your keyring...

+ wget -qO- https://www.phidgets.com/gpgkey/pubring.gpg | apt-key add -
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK

## Creating apt sources list file for the Phidgets Inc. repo...

+ echo 'deb https://www.phidgets.com/debian jammy main' > /etc/apt/sources.list.d/phidgets.list
+ echo 'deb-src https://www.phidgets.com/debian jammy main' >> /etc/apt/sources.list.d/phidgets.list

## Running `apt-get update` for you...

+ apt-get update
Hit:1 archive.ubuntucom/ubuntu jammy InRelease
Hit:2 archive.ubuntucom/ubuntu jammy-updates InRelease              
Hit:3 archive.ubuntucom/ubuntu jammy-backports InRelease            
Hit:4 security.ubuntucom/ubuntu jammy-security InRelease               
Hit:5 https://www.phidgets.com/debian jammy InRelease                     
Reading package lists... Done
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://www.phidgets.com/debian jammy InRelease' doesn't support architecture 'i386'

## Run `sudo apt-get install -y libphidget22` to install phidget22
## If you wish to develop against libphidget22 in C/C++:
     sudo apt-get install build-essential libphidget22-dev
## If you wish to develop in Java:
     sudo apt-get install default-jdk libphidget22java
## If you wish to develop in Python:
     pip3 install Phidget22
## To install the phidget22admin command line tool:
     sudo apt-get install phidget22admin
## To install the Phidget Network Server:
     sudo apt-get install phidget22networkserver phidget22wwwjs
## To install the legacy phidget20 libraries:
     sudo apt-get install libphidget21-0 libphidget21-dev libphidget21-java


Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libphidget22 is already the newest version (99:1.17.20230824-1ubuntu~22.04).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
So I still get an issue with 'i386' even though the architecture was added to phidgets.list

Code: Select all

	******************************  Logging Enabled  ******************************
	* Phidget22 - Version 1.17 - Built Aug 24 2023 14:02:06                       *
	* Release 1.17 - Linux (64-bit)                                               *
	*******************************************************************************
2023-08-29T22:26:48.000 <ERROR> www[handleWWWClient()] : failed to handle phidgets websocket connection
	server.c+650 handleDeviceClient() : (Access Denied) failed to start server connection
	network.c+1292 startServerConnection() : (Access Denied) failed to authenticate client
2023-08-29T22:26:51.000 <ERROR> www[handleWWWClient()] : failed to handle phidgets websocket connection
	server.c+650 handleDeviceClient() : (Access Denied) failed to start server connection
	network.c+1292 startServerConnection() : (Access Denied) failed to authenticate client
2023-08-29T22:26:51.000 <ERROR> www[handleWWWClient()] : failed to handle phidgets websocket connection
	server.c+650 handleDeviceClient() : (Access Denied) failed to start server connection
	network.c+1292 startServerConnection() : (Access Denied) failed to authenticate client
2023-08-29T22:26:55.000 <ERROR> www[handleWWWClient()] : failed to handle phidgets websocket connection
	server.c+650 handleDeviceClient() : (Access Denied) failed to start server connection
	network.c+1292 startServerConnection() : (Access Denied) failed to authenticate client
2023-08-29T22:33:53.000         last message repeated 1 more times
Running sudo apt-get update gives this:

Code: Select all

Reading package lists... Done
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://www.phidgets.com/debian jammy InRelease' doesn't support architecture 'i386'
I did notice that the /etc/apt/sources.list.d/phidgets.list reverts back to the original (without the [arch=amd64]) every time after I install. Is there maybe something else I should be doing too? I have tried running the manual installation with:

wget -qO- http://www.phidgets.com/gpgkey/pubring.gpg | sudo apt-key add - && sudo bash -c "echo 'deb [arch=amd64] http://www.phidgets.com/debian bullseye main' > /etc/apt/sources.list.d/phidgets.list"
(with the modified phidgets.list file)

Then I get this:

Code: Select all

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK
I tried fixing it with this, but no luck:

Code: Select all

user@user-VirtualBox:~$ wget -qO- http://www.phidgets.com/gpgkey/pubring.gpg | sudo apt-key add - && sudo bash -c "echo 'deb [arch=amd64] http://www.phidgets.com/debian jammy main' > /etc/apt/sources.list.d/phidgets.list"
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK

I would really appreciate any help you can give me.

Thanks, Neil

Re: Network server requires authentication

Posted: Tue Aug 29, 2023 4:20 pm
by Patrick
The warning about i386 arch is just a warning and should not affect anything. I've talked to Brian about helping you myself tomorrow, as I would like to get to the bottom of this.

-Patrick