added console.log to ws.onopen, ws.onclose and ws.onerror