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

Supporting Browser-based Javascript and Node.js
Post Reply
pos-informatique
Fresh meat
Posts: 2
Joined: Tue Jul 11, 2023 1:52 pm
Contact:

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

Post 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.
User avatar
Patrick
Lead Developer
Posts: 616
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

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

Post 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
pos-informatique
Fresh meat
Posts: 2
Joined: Tue Jul 11, 2023 1:52 pm
Contact:

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

Post 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:
Post Reply

Who is online

Users browsing this forum: No registered users and 45 guests