开发者

how to use fallbacks in socket.io for providing long polling on a websocket server?

开发者 https://www.devze.com 2023-04-02 03:21 出处:网络
I have an existing websocket server which serves json over websockets for IM on some non-http/s port.

I have an existing websocket server which serves json over websockets for IM on some non-http/s port.

This works fine for browsers which support websocket pr开发者_开发知识库otocol but leaves a lot of other browsers from using the feature.

I was reading up on socket.io and nodejs and was thinking of adding a proxy using socket.io and nodejs in front of the websocket server to handle all websocket requests. Since socket.io supports fallback using flash websockets or long polling, I was hoping that using socket.io on client side will allow support for all older browsers as well.

So, my questions are,

  1. Is the above approach feasible?
  2. How does the fallback to long polling have to be handled in nodejs? Is it handled automatically or needs to be implemented?
  3. Any existing resources which might help me out.

Thanks


  1. It can be made feasible. However I suggest using NodeJS and Socket.IO for both your non-http request and http request for browsers. NodeJS can handle them very easily.
  2. Socket.IO handles fallback automatically.
  3. A simple chat system example here for http.
0

精彩评论

暂无评论...
验证码 换一张
取 消