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
2
votes
0 answers

proxy_pass to websocket behind nginx

I got websocket servers and there are behind nginx. I need to configure second nginx as proxy to this first nginx. But when I make a request, there is an error 400 or 404 (with different configs). Here is my config of my nginx: map $http_upgrade…
Grzonu
  • 21
  • 3
2
votes
0 answers

NGINX Websocket initial communication delay

I've created a Django server that is making use of django-channels for websocket communication. When I run the server with NGINX there is an initial delay in websocket communication between the server and the client. After the initial delay all the…
MCBama
  • 121
  • 4
2
votes
2 answers

nginx as proxy for WebSocket: inspect and block certain requests

I ran NodeJS as a kind of Webapplication Server serving an AngularJS frontend. They communicate solely over WebSockets, using the SailsJS implementation of Socket.IO. Between frontend (client) and the NodeJS backend, sits nginx as a proxy,…
cis
  • 217
  • 2
  • 9
2
votes
1 answer

Does Apache process handling Websocket proxy also serve same client for http?

In choosing to adopt Websocket as the real-time technology behind a web application for my company, I'm trying to determine what the server workload will be. So far as I understand Apache internals, I believe an Apache process or thread will be kept…
Some Dude
  • 83
  • 2
2
votes
1 answer

Can not using websocket with nginx

I am using Activemq as broker, client side is Paho js to send websocket request(ws protocol). Everything work fine on server, but when the server start to set nginx as proxy, the client can not connect to server( but I can connect to Activemq UI…
Rong Nguyen
  • 121
  • 5
2
votes
1 answer

Websocket reverse proxy with nginx: Error about request in server log, but works in browser

The situation I am running Etherpad, which is proxied via nginx. Etherpad uses Websockets with Socket.io. My nginx config is more or less this one. The location block for socket.io is this: rewrite /CustomSubDir/socket.io/(.*) /socket.io/$1…
rugk
  • 466
  • 2
  • 6
  • 18
2
votes
3 answers

Configure Meteor in a server without websocket support

I was asked to test a meteor (js) website in a server without websockets support, how can I achieve this? How can I really know that a server is not capable of using websockets?
w3jimmy
  • 143
  • 5
2
votes
1 answer

How does nginx websocket proxy work?

I'm wondered about how nginx handles tons active websocket connections? There is a lot of limitations, like a number of open files, maximum of 65k TCP connections between IP <-> (IP, port) and so on. When I'm using nginx as reverse proxy and have,…
2
votes
0 answers

Sticky sessions with Apache load balancer for Socket.io 1.0

I've been messing around with Apache as a load balancer for my Socket.io server. I went through the following topic and now everything seems to be fine. Configuring Apache 2.4 mod_proxy_wstunnel for Socket.IO 1.0 I configured Apache using the…
2
votes
2 answers

WebSocket Connection vs. Repeated GETs

I am prototyping an application using nodejs. But this question refers to hypothetical large scale roll out. What is more demanding on a server and/or bandwidth: WebSocket stay alive connections or repeated client HTTP GET requests? For example…
Ross
  • 153
  • 1
  • 1
  • 6
2
votes
1 answer

How to fix ws and socket.io memory leak?

I have read that there is a memory leak occurring in both node.js websocket modules ws and socket.io. It has existed for years and am wondering how to fix it. It is mentioned in the following, to name a…
Normajean
  • 121
  • 1
  • 5
2
votes
1 answer

Tomcat servlet will not complete websocket connection

I am moving a set working servlets from one server to another Old server, Centos6, Apache 2.2, Tomcat 9 New Server, Centos7, Apache 2.4, Tomcat 9 I have about 5 servlets running from the old server all are OK, except the one servlet that has 3…
ScottD
  • 21
  • 4
1
vote
1 answer

No protocol handler was valid for the URL / (scheme 'ws')

Trying to setup a websocket proxy using apache2, I get the following error: No protocol handler was valid for the URL / (scheme 'ws'). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration…
Mohsen Saberi
  • 75
  • 1
  • 3
  • 7
1
vote
1 answer

Connecting to websocket on Google Cloud Run docker container

I'm rather a newbie to GCP so please forgive my ignorance. I'm trying to connect a few bits together, namely: A Node instance running on App Engine A ChatScript instance running on Cloud Run with a Dockerfile An SQL instance running on Cloud…
1
vote
1 answer

Nginx: proxy_set_header "Upgrade" slows down the server

I have a site that I'd like to enhance with using WebSocket based features. The site is behind an Nginx reverse proxy. My config for the server looks like this: location / { proxy_set_header X-Forwarded-Server $host; …
László Stahorszki
  • 220
  • 1
  • 5
  • 14