how to use fallbacks in socket.io for providing long polling on a websocket server?
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,
- Is the above approach feasible?
- How does the fallback to long polling have to be handled in nodejs? Is it handled automatically or needs to be implemented?
- Any existing resources which might help me out.
Thanks
- 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.
- Socket.IO handles fallback automatically.
- A simple chat system example here for http.
精彩评论