-
• #2
Your code above is not like the client here - the port is passed as an option
The client assumes there is a server on that ip and port - what do you have running as a server?
-
• #3
I tried the example but that didn't work either. Infact the code didn't work on the desktop either.. When running like a Websocket client . I was getting a "invalid url" error on the desktop.
I changed the code to what it is now and atleast it began working with a WebSocket server (code below) and the WebSocket client when both are running on the desktop
var WebSocketServer = require('ws').Server, wss = new WebSocketServer({ port: 8080 }); wss.on('connection', function connection(ws) { ws.room = []; ws.send("User Joined"); ws.on('message', function(message) { console.log("Msg from client - " + message); ws.send("Echo from Server " + message); }); ws.on('error', function(er) { console.log(er); }) ws.on('close', function() { console.log('Connection closed') }) });
I am trying to follow this example to setup a sample Websocket Client but the client won't connect nor does it thrown an error. None of the callback functions are ever called.
I made sure that the WiFi is connected before the Websocket is initialized. The server doesn't see that the client running on Espruino on an ESP8266 is even connected. Does the built-in Websocket support the built in @require("Wifi") model?
This same code runs fine when run from the Mac console when the websocket client is running inside the Mac and the server is also on the Mac.
I have verified that the HTTP object is able to call another Web-server on the Mac.. So its definitely not a connectivity issue.
Just need to know if the WebSocket object knows to utilize the connection as established by the Wifi.connect() API.