Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can websocket client connect to the websocket server from different ports other than 80/443

Tags:

html

websocket

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 -

  1. The websocket client will connect to the server by port 80/443, and its protocol identifier is ws/wss accordingly. http://www.websocket.org/aboutwebsocket.html
  2. The Apache/Nginx web server commonly will listen to 80/443 at server-side, so we have to config Apache/Nginx to support ws/wss protocol, better transmit the connection to a websocket server like a proxy do.
  3. There are some websocket server add-on for Apache, also I know Nginx 1.3+ support websocket protocol natively, and it's fine to config it as well working with a websocket server.

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 ?

like image 339
Tom Avatar asked Mar 31 '13 13:03

Tom


People also ask

Does WebSocket use different port?

By default the WebSocket protocol uses port 80 for regular WebSocket connections and port 443 for WebSocket connections tunneled over TLS [RFC2818].

Can a client have multiple WebSocket connections?

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.

Can WebSocket run on port 80?

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.

How many connections can a WebSocket server handle?

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).


1 Answers

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.

like image 193
zaphoyd Avatar answered Oct 21 '22 13:10

zaphoyd