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
0
votes
1 answer

What is the fastest posible way to comunicate to a server on Amazon EC2?

I need to communicate via WebSockes and normal HTTP. I am trying to save some microseconds. I have already done: I got an instance at the same Amazon EC2 zone. The ping is 1 millisecond. I have translated the application from Perl to Julia. It is a…
0
votes
0 answers

How to distribute socket.io servers globally?

We have a Socket.io service that needs constant communication with Mongodb. We currently have a load balancer server, 16 containers in a server (due to nodejs being single threaded, we split processes by dockers so we can utilize entire server) and…
Ümit Yayla
  • 11
  • 1
  • 4
0
votes
0 answers

Cannot connect to websocket

When I tried to connect to spring boot web socket from android stomp client, it is not connecting and the catalina log shows Handshake failed due to invalid Upgrade header: null Tomcat server is running behind apache and the apache server runs on…
Sony
  • 103
  • 1
  • 6
0
votes
1 answer

Azure WebApp Socket can't connect

I have a ASP .NET application hosted as a WebApp in Azure and a Xamarin client app that consumes that WebApi in Azure. As soon as I changed my webapi to an Azure WebApp, which was previously hosted in non-azure VM and it was working fine, my Xamarin…
0
votes
1 answer

Redirect websocket and json in SSL with NGINX

I'm getting crazy to solve a problem with the neginx configuration of a live blogging platform. In http it works, and here is the configuration: /etc/nginx/conf.d/default.conf server { listen 80 default; include…
Roberto Pezzali
  • 139
  • 1
  • 6
0
votes
1 answer

Nginx websoket reverse proxy caching

I'm currently using nginx to reverse proxy a websocket based application. Can I enable caching websocket messages to make the application available when service behind is down? I know caching is possible for HTTP requests as documented here. Is…
TRiNE
  • 103
  • 3
0
votes
1 answer

Nginx + Socket.io + Proxy

After reading several articles, I'm still unable to get my socket.io communication working via a nginx proxy. Below is my nginx configuration: map $http_upgrade $connection_upgrade { default upgrade; '' close; } location ~* \.io { …
0
votes
1 answer

Nginx: How to log the number of bytes sent over a websocket?

I am using nginx as a websocket reverse-proxy. I would like to log the number of bytes sent (and ideally also received) over a websocket. If I use $body_bytes_sent in log_format, the entry in the access_log is always 0. As far as I can tell, a lot…
seeker6
  • 1
  • 3
0
votes
1 answer

High CPU load in a data aquisition server

I`ve setup a small python program that uses a websocket connection to acquire data from an API and write it to a postgresql database. There are only two (user) programs running: the websocket connection that receives data and write it to the…
Alex
  • 121
  • 2
0
votes
1 answer

How to make TCP server in node.js sticky?

This is a TCP server for receiving data from GPS server const net = require('net'); const lora_packet = require('lora-packet'); const clients = []; const server = net.createServer(function (socket) { socket.name = socket.remoteAddress + ":"…
0
votes
1 answer

nginx: [emerg] unknown directive "<^>upstream"

I'm configuring nginx as a reverse proxy. I have the following in my nginx.conf: user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 768; } http { sendfile on; …
0
votes
0 answers

TCP Reconnect to Unknown Address with Websocket when there is no Internet

I have used ProcMon.exe to see what happens to my application when there is no internet. My application is an electron application that makes use of websocket to connect to backend service resides in other computer. FYI, the example of websocket…
0
votes
1 answer

forwarding proxmox vnc websocket with nginx

I installed nginx in order to be a lazy person and just go to proxmox.domain.com instead of proxmox.domain.com:8006, but now I can't access the VNC client when connected to the first address, although I can doing the ip+port. A friend of mine…
Seth G.
  • 101
  • 2
0
votes
1 answer

Cannot connect through WebSockets with nginx proxy

My setup consists in a headless Chrome instance running on http://localhost:9222. It works if I connect to it directly through a WebSocket client. I would like to put a Nginx server block as a proxy in front of it (I'll add authentication, etc,…
0
votes
1 answer

In Apache how do I configure a sub-url redirection to socket.io?

I got a simple node.js websocket server: var io = require('socket.io')(12345); io.on('connection', function(socket){ console.log('a user connected'); socket.on('disconnect', function(){ console.log('user disconnected'); }); …
Nelson Teixeira
  • 225
  • 1
  • 3
  • 15