Socket.io 具有非 socket.io 服务器的客户端

Socket.io client with non-socket.io server

我正在尝试使用 socket.io 客户端连接到非 socket.io websocket 服务器。但我做不到。 我正在尝试像这样连接到套接字服务器:

var socket = io.connect('wss://url-to-socket-api/');

并得到错误:

XMLHttpRequest cannot load https://url-to-socket-api/socket.io/?EIO=3&transport=polling&t=1452852826678-0. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.33.10' is therefore not allowed access. 

但是当我像这样使用网络套接字API连接到服务器时:

var socket = new WebSocket('wss://url-to-socket-api');

有效。

是否可以将 socket.io 客户端与非 socket.io 服务器一起使用?

我们不能将 Socket.io 客户端与非 socket.io 服务器一起使用。在这种情况下使用 WebSocket。链接很少:

http://www.developerfusion.com/article/143158/an-introduction-to-websockets/

http://code.tutsplus.com/tutorials/start-using-html5-websockets-today--net-13270