I am a novice on Websocket programming, but my latest project required to deploy a WebSocket Server on Ubuntu Linux Server. I have read some from the internet, and know -
Based on what I knew, I think I can deploy Apache/Nginx and a Websocket Server together through 80/443. I am wondering, if we can just use the websocket server indepdently? I think if we can write a websocket client connecting to the server from other ports , then we can do it.
So can we write a websocket client to connect the server from different port ?
By default the WebSocket protocol uses port 80 for regular WebSocket connections and port 443 for WebSocket connections tunneled over TLS [RFC2818].
A server can open WebSocket connections with multiple clients—even multiple connections with the same client. It can then message one, some, or all of these clients. Practically, this means multiple people can connect to our chat app, and we can message some of them at a time.
Although they are different, RFC 6455 states that WebSocket "is designed to work over HTTP ports 443 and 80 as well as to support HTTP proxies and intermediaries", thus making it compatible with HTTP.
The theoretical limit is 65k connections per IP address but the actual limit is often more like 20k, so we use multiple addresses to connect 20k to each (50 * 20k = 1 mil).
Yes. A standalone WebSocket server can usually be run on any port. Browser clients have no problem opening WebSocket connections to servers on non HTTP(S) ports.
The primary reason that the default ports are 80/443 is that they are the most reliable ports for mass usage due to their ability to traverse many corporate firewalls that block all traffic on all other ports.
If this will not be a problem for your audience (or you have HTTP based fallbacks) it is perfectly reasonable (and a lot easier) to use alternate ports for the WebSocket servers. Another option is to use the 80/443 ports but on a separate IP address/hostname.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With