dynamically set websocket url connect socket.io code example
Example 1: socketio connect websockets
var ws = new WebSocket('ws://localhost/socket.io/?EIO=3&transport=websocket');
ws.send('42' + JSON.stringify(['hello', 'there']));
// ws.onmessage will get a MessageEvent object with the data property being encoded in the similar way.
Example 2: socketio connect websockets
var socket = io('http://localhost');
socket.emit('hello', 'there');