WebSocket is already in CLOSING or CLOSED state.value @ VM3171:338(anonymous function) @ plx_exchage.js?v=0716-6:2207
VM3171:320 WebSocket connection to 'wss://api2.poloniex.com/' failed: WebSocket is closed before the connection is established.
The problem is that the page closes WS itself with the following code:
window.conn.onmessage = function(e){
if (e.target.connectionID != webSocketConnectionID)
return e.target.close();
.... code here ....
}
The root cause of this issue is that e.target object is the real WebSocket object and not our wrapper which contains the connectionID field.
To fix this issue we should not simply pass through the on* properties. Instead we should wrap them in our own function which will set the e.target field to the wrapper object.
Steps to reproduce:
The problem is that the page closes WS itself with the following code:
The root cause of this issue is that
e.target
object is the real WebSocket object and not our wrapper which contains theconnectionID
field.To fix this issue we should not simply pass through the
on*
properties. Instead we should wrap them in our own function which will set thee.target
field to the wrapper object.