Socket.io - Ports, Protocols and Proxies
I'm building a system on Nodejs & Socket.io providing real time events to clients (inc. mobile).
I understand with websockets there can be issues traversing some proxies due to its HTTP like handshake, and that you're likely to get greater reliability by using websocke开发者_JS百科ts secure because of it.
It is important to avoid issues caused by choice of port and protocol. For maximum compatibility would port 80 be the best choice to avoid closed ports in businesses etc? And is socket.io SSL more reliable in the same way as wss is?
Thanks in advance for the advice!
SSL isn't one of node's strong points, but the dev team is working hard on that. So I wouldn't say that SSL is more reliable.
As for the ports / proxies.. It's a nightmare, you have firewalls that block ports other than port 80. And you have virus scanners that block websockets and other polling requests and do allow it on different ports.
For our site we found out that about 5% of all our visitors where unable to access port 4000. Which is quite a large sum.
So there really isn't a ideal port.. But if you would just advise you to use port 80 and maybe provide a fallback to port 8080 so that when a you get a connect_failed event from socket.io you can try to connect over a different port.
On the serverside you can probably do some simple port forwarding for this using IPTables but I'm sure google could tell you more about that as it's not my strongest points ;D
Anyways, hope this helps.
精彩评论