I need to connect to a external websocket using node JS,but every single tutorial I find online is only about creating server/client and connecting to each other. I already have an external url with a websocket i need to access (even tho it is connected to my network,i have no control over it, so i won't be creating a server or anything like that). It is that simple; Connecting to a external URL using Node JS Websocket/socket.io. So far i have this code, but there is a great chance that it is completely wrong, as im not very experienced in Node JS. So feel free to completely change it. No need to try to upgrade it.
io = require('socket.io-client');
var socket = io.connect('MY.WEBSOCKET.ADDRESS');
function doStuff(){
//Listener
socket.on('connection', function(){
try {
console.log('connected!');
}
});
}
doStuff();
What am i getting wrong?