Create Websocket Connection Javascript Foreach With Index