Socket.io-client: Socket.io can't connect to WebSockets (only)

Created on 22 May 2018  ·  6Comments  ·  Source: socketio/socket.io-client

You want to:

  • [x] report a bug
  • [ ] request a feature

Current behaviour

I connect to a WebSocket using Socket.io and no connection will be established.
The WebSocket server (PHP Ratchet) detects a connection but this will be closed soon and Socket.IO never says that the client is connected to the server.

Steps to reproduce (if the current behaviour is a bug)

var conn = io('wss://demos.kaazing.com/echo', { upgrade: false, transports: ['websocket'] });

Error: Error during WebSocket handshake: Unexpected response code: 403

This is working:

var conn = new WebSocket('wss://demos.kaazing.com/echo');

-> Tested in the console of https://socket.io/get-started/chat/ <-

Expected behaviour

That socket.io can handle the WebSocket 👍

Setup

  • OS: Windows 10
  • browser: Google Chrome 66.0.3359.181 (Official Build) (64-bit)
  • socket.io version: 1.3.5 and 2.1

All 6 comments

@patrickbussmann actually, Socket.IO is not a WebSocket implementation, it has its own protocol which may use a WebSocket connection to transmit data.

But i think When i specify it in the options it should use only websockets.

Do you know how to use Ratchet PHP with Socket.IO?
It Supports http Server etc also.
But tested and not works.

@patrickbussmann Brother, I also encountered this problem, I want to find a websocket tool,but this seems to be used only Socket.io as server side.Have you found a solution?

Hi @hongweipeng,
Im using new WebSocket() direct instead of using Socket.IO client.

@patrickbussmann Well,Im also going to use the same way as you, thx.

emmm socket.io-client connected java websocket, but don't know how to exchange message

Was this page helpful?
0 / 5 - 0 ratings