首页 文章

带有nonsocket.io服务器的Socket.io客户端

提问于
浏览
1

我尝试使用socket.io客户端连接到nonsocket.io websocket服务器 . 但我不能这样做 . 我正在尝试连接到socket服务器,如下所示:

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.

但是,当我使用Web套接字API连接到服务器时,如下所示:

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

其作品 .

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

1 回答

相关问题