Questions tagged [websocket]

WebSocket is an API built on top of TCP sockets and a protocol for bi-directional, full-duplex communication between client and server without the overhead of http.

WebSockets (or WebSocket) is an API and a protocol for bi-directional, full-duplex communication over TCP sockets. The WebSockets API was originally part of the HTML5 standard, but it has been split off into a separate W3C standard. The WebSockets protocol is an IETF standard described in RFC 6455.

The WebSockets API has full browser support in Chrome 14, Firefox 6, IE 10 (desktop and mobile), Opera 12.1 (desktop and mobile), Safari 6.0 (desktop and mobile), Android 4.4, Chrome Mobile, and Firefox Mobile. Some older browsers have partial support or can be supported using a Flash based fallback.

WebSockets supports both unencrypted and encrypted connections. Unencrypted connections use the "ws://" URL scheme and default to port 80. Encrypted connections use the "wss://" URL scheme and default to port 443. Encrypted connections use Transport Layer Security (TLS).

Simple WebSockets browser JavaScript example:

if ("WebSocket" in window) {
    var ws = new WebSocket("ws://echo.websocket.org/");
    ws.onopen = function() {
        console.log("WebSockets connection opened");
        ws.send("a test message");
    }
    ws.onmessage = function(e) {
        console.log("Got WebSockets message: " + e.data);
    }
    ws.onclose = function() {
        console.log("WebSockets connection closed");
    }
} else {
    // No native support
}

Useful Links

Books

185 questions
45
votes
5 answers

Configuring Apache2 to proxy WebSocket?

The WebSocket protocol is an extension of the HTTP protocol. However, the proxy module of Apache2 does not seem to know about it, and throws away crucial headers, converting the call to a standard HTTP call. Is there a way to make Apache2 either (1)…
Blixt
  • 595
  • 1
  • 4
  • 7
9
votes
1 answer

Proxy Websockets and HTTP through the same location in Nginx

Right now there's an application that allows people to connect to a Desktop app through the web by exposing an AngularJS web server powered by Atmosphere. The Desktop app exposes the current person's IP address so anyone with the address can connect…
Jose A
  • 193
  • 1
  • 1
  • 5
9
votes
2 answers

Apache mod_proxy: forward secure websocket to non-secure

The websocket library I rely on (PHP-Websockets) does not yet support secure sockets (wss). My website is served over https though, so I cannot use insecure ws connections. I'm trying to use Apache's mod_proxy to forward the secure request that…
BeetleJuice
  • 411
  • 2
  • 4
  • 11
9
votes
2 answers

Scale HAProxy for more than 64k websockets

We are trying to design an architecture that will be able to handle more than 64k websockets. We first tried with Amazon ELB, but its design doesn't allow unexpected spike of traffic nor websocket. (TCP mode timeout the websockets unexpectedly) With…
Bastien974
  • 1,824
  • 12
  • 43
  • 61
8
votes
1 answer

ProxyPass a WebSocket connection to a UNIX socket

In Apache 2.4 you can reverse proxy an HTTP connection to a local Unix socket with: [1] ProxyPass unix:/path/to/app.sock|http://example.com/app/name You can reverse proxy a WebSocket connection to a local TCP socket with: [2] ProxyPass…
kay
  • 191
  • 1
  • 8
8
votes
1 answer

Nginx WebSocket reverse proxy keeps return 200 instead of 101

I'm currently trying to have a hack.chat on my personal server working. Long story short, it consists of two servers. The first is a simple httpd server serving javascript and CSS. The second one, the chat system, is a node.js server which the…
axellink
  • 83
  • 1
  • 7
7
votes
1 answer

ws protocol and apache mod_proxy_wstunnel configuration: error 500

I got an error 500 when trying to access to ws://localhost:8080/ via my Apache2 server. This server runs OpenSuse Leap 42.1 and Apache 2.4.16. These Apache2 modules are enabled: mod_proxy, mod_proxy_http, mod_proxy_wstunnel. When the request is…
jack-y
  • 171
  • 1
  • 1
  • 2
6
votes
2 answers

Kubernetes Ingress: How can I expose two ports on one path?

I have a GCE Ingress configured and working with SSL on port 443. I'm trying to get port 28080 pointing to my standalone actionable server. I currently have this for my Ingress yaml: # web-ingress.yaml apiVersion: extensions/v1beta1 kind:…
Archonic
  • 314
  • 2
  • 5
  • 13
6
votes
1 answer

How to handle 1M websocket connections (Nginx/HAProxy/Amazon/Google)

What nginx or haproxy setup is suggested for target 100K concurrent websocket connections? What I think, a single nginx will not be able to take such traffic as well as concurrent connections. How should traffic to nginx/haproxy be split (DNS lvl or…
Ravi Kumar
  • 195
  • 1
  • 1
  • 4
6
votes
2 answers

Proxying websocket traffic from nginx 1.3.13 to socket.io (without SSL)

As of 2 days ago, nginx started to support websocket connections, therefore I was trying to get my nginx-nodejs-socket.io application to work without HAproxy ect (not much luck though). What I want exactly to achieve is nginx to send only websocket…
Skeptic
  • 191
  • 1
  • 1
  • 6
5
votes
1 answer

HA Proxy and Websockets

I'm setting up my first HAProxy reverse proxy server. It's going to be a proxy for an HTML5 app running on tomcat from a different server. I was able to get it to proxy out via HTTP, redirect all requests to HTTPS, and implement HSTS. However,…
JoeInVT
  • 85
  • 1
  • 5
4
votes
1 answer

Add proxy headers in named location using nested location regex

I'm trying to setup a WebSocket endpoint on my Rails API using Nginx and Puma. What I have (working but ugly) The following Nginx configuration works fine, however I feel like I could use something more clever to avoid duplication on both @puma and…
Habovh
  • 271
  • 3
  • 12
4
votes
1 answer

Unable to get websockets to work through apache HTTPS proxy (302 error)

I'm unable to make websockets work on a node backend using an apache proxy through HTTPS to connect to the node instance. Websockets are working properly if no (apache) http(s) proxy is used. My setup: I have an apache server with multiple virtual…
4
votes
1 answer

TeamCity, nginx, and Websockets - 501 Error

I'm currently setting up TeamCity behind an nginx reverse proxy, but I am getting an error in my browser. The error is as follows: WebSocket connection to…
mattrick
  • 143
  • 1
  • 1
  • 9
4
votes
1 answer

Application layer firewall for WebSockets?

My team has built an intranet portal in Amazon AWS for a client, and on it, we have used WebSockets to do things like notifications and other minor stuff. We mostly send events from the server, but we also use it so the client can quickly notify the…
Mike Caron
  • 237
  • 2
  • 13
1
2 3
12 13