Dmytro Medvid
Dmytro Medvid

Reputation: 5228

Socket.io client with non-socket.io server

I trying to connect to the non-socket.io websocket server using socket.io client. But I can't to do it. I'm trying to connect to socket server like this:

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

And getting the error:

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. 

But when I connect to the server with web socket API like this:

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

It's works.

Is it possible to use socket.io client with non-socket.io server?

Upvotes: 5

Views: 1839

Answers (1)

Dmytro Medvid
Dmytro Medvid

Reputation: 5228

We can't use Socket.io client with non-socket.io server. In this case use WebSocket. There is few links:

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

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

Upvotes: 5

Related Questions