Page 1 of 1

Wireless VINT Hub - phidget22.min.js:7 WebSocket connection to 'ws://192.168.100.1:5661/phidgets' failed

Posted: Tue Jul 11, 2023 2:03 pm
by pos-informatique
Hello,

On my computer, I connected with wifi to a Wireless VINT Hub (With the 192.168.100.1 ip address).
I created a simple HTML page with the following script :

Code: Select all

<html>
    <body onload="load()">
        <script src="phidget22.min.js"></script>
    </body>
    <script>
        async function load() {
            const conn = new phidget22.NetworkConnection(5661, '192.168.100.1');
	    await conn.connect();
        }
    </script>
</html>
When I execute this page I have the following error my Chrome browser :
WebSocket connection to 'ws://192.168.100.1:5661/phidgets' failed

But if I execute the following code in Node.JS :

Code: Select all

const phidget22 = require('phidget22');

async function runExample() {
    const conn = new phidget22.NetworkConnection(5661, '192.168.100.1');
    await conn.connect();
    // ...
}

runExample();
It is work...
So the problem does not come from the configuration of my VINT Hub but an issue using the Phidget library with JavaScript (in plain mode in a HTML page)...

Where the problem come from ?

Thanks in advance for your answers.

Re: Wireless VINT Hub - phidget22.min.js:7 WebSocket connection to 'ws://192.168.100.1:5661/phidgets' failed

Posted: Tue Jul 11, 2023 3:53 pm
by Patrick
The browser API uses a different port to connect than Node.js - 8080 by default (because it's using the websocket protocol while Node.js uses regular sockets).

-Patrick

Re: Wireless VINT Hub - phidget22.min.js:7 WebSocket connection to 'ws://192.168.100.1:5661/phidgets' failed

Posted: Tue Jul 11, 2023 4:44 pm
by pos-informatique
Hello Patrick,

Thanks it's work now! :D
I just remarked on the VINT Hub portal it was writing "The webserver is required for JavaScript in-browser clients."... :?:oops: