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

197 questions
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
0
votes
0 answers

nginx reverse proxies with separate SSL termination and websockets

I'm trying to chain proxies. The first one for SSL, next one - for dispatching to the servers. The first one (secure-gateway-nginx) just unwraps SSL and passes to the gateway-nginx: server { listen 443 ssl; server_name secure-gateway-nginx; …
Velkan
  • 344
  • 3
  • 19
0
votes
0 answers

websocketserver behind nginx and apache

How is it possible to establish a websocket connection through nginx and apache, where both act as reverse proxies. The system is setup with apache on the main host and a tornado webapplication in a container. My apache config d is as…
eatdas
  • 1
  • 1
0
votes
1 answer

Unable to init NodeJS-based WebSocket Server as Service on Windows Server 2012

A basic node.js Implementation of a websocket server runs fine as when started via the command line or the scheduled task manager. However, after being installed as a service using nssm, it refuses to launch with the following exception: windows…
0
votes
0 answers

can many users on 1 wifi network cause issues with websockets?

We have a product that allows a group of people watching a presentation to vote on questions in the presentation on their mobile. The new version of the website that people use to vote uses websockets, for example to get notifications if a vote has…
Flion
  • 181
  • 1
  • 2
  • 9
0
votes
0 answers

elb ssl termination for wss websocket fails net::ERR_RESPONSE_HEADERS_TRUNCATED

I am trying to get a websocket communication working through a classic ELB with ssl termination to wowza, a java based media server. Setup VPC R53 test.myTld.com IPv4, Alias=Yes, Target myElb, Routing Simple CLASSIC ELB: myElb listeners: SSL…
art vanderlay
  • 171
  • 1
  • 4
0
votes
1 answer

Apache2: Is Proxy from https to http secure

Im pretty new at all this server stuff, and I have a question regarding the security of the apache proxy. What I am doing is: I have a websocket server running in non secure mode on port 11221 on the same system (localhost only, but with apache,…
Felix
  • 103
  • 2
0
votes
1 answer

Cannot connect to server via wss

I have the below nginx.conf file set to handle http and https. I'm currently using a self-signed certificate to test over ssl. server { listen 80; listen 443 ssl; server_name localhost; ssl_certificate…
Jayaram
  • 153
  • 1
  • 1
  • 7
0
votes
0 answers

Nginx, Way to re-balance websocket for a server which gets alive after failed?

I want to balance web-socket with Nginx. When it connects first, it balances the connections. When a server among upstream is failed, it also does re-balance web-socket connections. However, even when the server is recovered, Nginx still retain the…
asleea
  • 159
  • 1
  • 1
  • 9
0
votes
1 answer

PHP websocket script running as daemon stops working after a while

I start my websocket script like so: nohup php server.php & and I close the ssh client and it seems to be working fine for a while, but after say half an hour or so it stops working, any idea why and how to make it permanent?