Skip to main content

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 HTTP overhead.

Filter by
Sorted by
Tagged with
1222 votes
8 answers
340k views

WebSockets vs. Server-Sent events/EventSource [closed]

Both WebSockets and Server-Sent Events are capable of pushing data to browsers. To me they seem to be competing technologies. What is the difference between them? When would you choose one over the ...
Mads Mobæk's user avatar
  • 35.5k
1197 votes
4 answers
217k views

What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?

I have tried reading some articles, but I am not very clear on the concepts yet. Would someone like to take a shot at explaining to me what these technologies are: Long Polling Server-Sent Events ...
user1437328's user avatar
  • 15.7k
696 votes
12 answers
342k views

Differences between socket.io and websockets

What are the differences between socket.io and websockets in node.js? Are they both server push technologies? The only differences I felt was, socket.io allowed me to send/emit messages by ...
Vivek Mohan's user avatar
  • 8,218
456 votes
10 answers
158k views

Does HTTP/2 make websockets obsolete?

I'm learning about HTTP/2 protocol. It's a binary protocol with small message frames. It allows stream multiplexing over single TCP connection. Conceptually it seems very similar to WebSockets. Are ...
vbezhenar's user avatar
  • 12k
453 votes
3 answers
248k views

Which websocket library to use with Node.js? [closed]

Currently there is a plethora of websocket libraries for node.js, the most popular seem to be: https://github.com/Worlize/WebSocket-Node https://github.com/einaros/ws https://github.com/LearnBoost/...
balupton's user avatar
  • 48k
452 votes
6 answers
206k views

WebSockets protocol vs HTTP

There are many blogs and discussions about WebSocket and HTTP, and many developers and sites strongly advocate WebSockets, but I still can not understand why. For example (arguments of WebSocket ...
4esn0k's user avatar
  • 10.2k
417 votes
18 answers
504k views

HTTP headers in Websockets client API

Looks like it's easy to add custom HTTP headers to your websocket client with any HTTP header client which supports this, but I can't find how to do it with the web platform's WebSocket API. Anyone ...
Julien Genestoux's user avatar
323 votes
4 answers
123k views

In what situations would AJAX long/short polling be preferred over HTML5 WebSockets?

I am building a small chat application for friends, but unsure about how to get information in a timely manner that is not as manual or as rudimentary as forcing a page refresh. Currently, I am ...
somdow's user avatar
  • 6,298
309 votes
8 answers
157k views

WebRTC vs WebSocket: If WebRTC can do Video, Audio, and Data, why do I need WebSocket? [closed]

So I'm looking to build a chat app that will allow video, audio, and text. I spent some time researching into WebSocket and WebRTC to decide which to use. Since there are plenty of video and audio ...
1ManStartup's user avatar
  • 3,786
291 votes
6 answers
199k views

Difference between socket and websocket?

I'm building web app that needs to communicate with another application using socket connections. This is new territory for me, so want to be sure that sockets are different than websockets. It seems ...
Jonathon's user avatar
  • 2,943
278 votes
12 answers
361k views

Debugging WebSocket in Google Chrome

Is there a way, or an extension, that lets me watch the "traffic" going through a WebSocket? For debugging purposes I'd like to see the client and server requests/responses.
mellowsoon's user avatar
275 votes
1 answer
213k views

What browsers support HTML5 WebSocket API?

I am going to develop an instant messaging application that runs in the browser. What browsers support the WebSocket API?
Sareuon's user avatar
  • 2,767
248 votes
13 answers
360k views

Send message to specific client with socket.io and node.js

I'm working with socket.io and node.js and until now it seems pretty good, but I don't know how to send a message from the server to an specific client, something like this: client.send(message, ...
Rodolfo Palma's user avatar
228 votes
7 answers
111k views

Why use AJAX when WebSockets is available?

I've been using WebSockets for a while now, I have chosen to create an Agile project management tool for my final year project at University utilizing Node server and WebSockets. I found using ...
Jack's user avatar
  • 15.8k
227 votes
2 answers
195k views

Differences between TCP sockets and web sockets, one more time [duplicate]

Trying to understand as best as I can the differences between TCP socket and websocket, I've already found a lot of useful information within these questions: fundamental difference between ...
pierroz's user avatar
  • 7,829
221 votes
4 answers
70k views

What is the fundamental difference between WebSockets and pure TCP?

I've read about WebSockets and I wonder why browser couldn't simply open trivial TCP connection and communicate with server like any other desktop application. And why this communication is possible ...
xap4o's user avatar
  • 2,906
210 votes
3 answers
135k views

Good beginners tutorial to socket.io? [closed]

I am very new to the world of webdevelopment and jumped into the bandwagon because I find the concept of HTML5 very interesting. I am fairly confident on working with canvas and would now like to move ...
Shouvik's user avatar
  • 11.6k
202 votes
2 answers
162k views

How do you inspect websocket traffic with Chrome Developer Tools? [duplicate]

I'm trying to inspect websocket traffic using Chrome Developer Tools. From my research it seems you should be able to see it using the network tab - and it even has a filter for 'ws'. However I've ...
Joel Duckworth's user avatar
190 votes
13 answers
255k views

node.js, socket.io with SSL

I'm trying to get socket.io running with my SSL certificate however, it will not connect. I based my code off the chat example: var https = require('https'); var fs = require('fs'); /** * Bootstrap ...
Beyond's user avatar
  • 2,070
189 votes
12 answers
251k views

WebSocket: How to automatically reconnect after it dies

var ws = new WebSocket('ws://localhost:8080'); ws.onopen = function () { ws.send(JSON.stringify({ .... some message the I must send when I connect .... })); }; ws.onmessage = function (e) {...
samol's user avatar
  • 20.1k
189 votes
2 answers
89k views

How many system resources will be held for keeping 1,000,000 websocket open? [closed]

Websocket is good, but would it be able to handle 1,000,000 concurrent connections? How many system resources will be needed for keeping 1,000,000 websocket open? Thanks!
k.k. lou's user avatar
  • 1,955
189 votes
6 answers
180k views

Maximum concurrent Socket.IO connections

This question has been asked previously but not recently and not with a clear answer. Using Socket.io, is there a maximum number of concurrent connections that one can maintain before you need to add ...
Andrew's user avatar
  • 14.4k
185 votes
4 answers
194k views

Sending websocket ping/pong frame from browser

I keep reading about ping/pong messages in websockets to keep the connection alive, but I'm not sure what they are. Is it a distinct frame type? (I don't see any methods on a javascript WebSocket ...
danny's user avatar
  • 10.4k
179 votes
5 answers
100k views

What is the difference between WebSocket and STOMP protocols?

What are the major differences between WebSocket and STOMP protocols?
LancerSung's user avatar
  • 1,811
173 votes
5 answers
48k views

Do HTML WebSockets maintain an open connection for each client? Does this scale?

I am curious if anyone has any information about the scalability of HTML WebSockets. For everything I've read it appears that every client will maintain an open line of communication with the server. ...
rmontgomery429's user avatar
164 votes
7 answers
199k views

How can I get the sha1 hash of a string in node.js?

I'm trying to create a websocket server written in node.js To get the server to work I need to get the SHA1 hash of a string. What I have to do is explained in Section 5.2.2 page 35 of the docs. NOTE:...
Eric's user avatar
  • 2,936
159 votes
4 answers
55k views

My Understanding of HTTP Polling, Long Polling, HTTP Streaming and WebSockets

I have read many posts on SO and the web regarding the keywords in my question title and learned a lot from them. Some of the questions I read are related to specific implementation challenges while ...
Software Guy's user avatar
  • 3,280
153 votes
3 answers
104k views

Which WebSocket library to use in Android app? [closed]

I want to add a Service to my Android app which runs in the background holding a WebSocket connection (possibly over several hours or even days) and regularly sends some data to a server. Now there ...
x-ray's user avatar
  • 3,319
151 votes
8 answers
437k views

Getting the reason why websockets closed with close code 1006

I want to get the reason websockets closed so that I can show the right message to the user. I have sok.onerror=function (evt) {//since there is an error, sockets will close so... sok....
slevin's user avatar
  • 4,402
145 votes
3 answers
78k views

Loadbalancing web sockets

I have a server which supports web sockets. Browsers connect to my site and each one opens a web socket to www.mydomain.example. That way, my social network app can push messages to the clients. ...
John Smith's user avatar
  • 3,167
144 votes
7 answers
233k views

Closing WebSocket correctly (HTML5, Javascript)

I am playing around with HTML5 WebSockets. I was wondering, how do I close the connection gracefully? Like, what happens if user refreshes the page, or just closes the browser? There is a weird ...
Andy Hin's user avatar
  • 31.2k
142 votes
4 answers
213k views

WebSocket with SSL

Is it possible to have WebSockets with HTTPS? When switching to HTTPS, my WebSocket returns a security error and works perfectly with regular HTTP. Below, a snippet; socket = new WebSocket("ws://...
Eric's user avatar
  • 10.3k
142 votes
2 answers
112k views

What is the difference between grpc and websocket? Which one is more suitable for bidirectional streaming connection?

I want to develop a client-server application in a bi-directional streaming manner. what is more suitable technology for this, grpc or websocket?
prashant sindhu's user avatar
136 votes
14 answers
217k views

WebSockets and Apache proxy: how to configure mod_proxy_wstunnel?

I have : Apache 2.4 on port 80 of my server, with mod_proxy and mod_proxy_wstunnel enabled Node.js + socket.io on port 3001 of the same server Accessing example.com (with port 80) redirects to 2. ...
Basj's user avatar
  • 44.8k
133 votes
3 answers
71k views

Differences between webhook and websocket?

I've always wanted to do a real-time chat. I've done that years ago in PHP+Ajax+Mysql and broke my server. Then I tried with Flash+ a text file. I gave up and haven't tried in 10 years. But recently I ...
David 天宇 Wong's user avatar
131 votes
6 answers
315k views

javax.websocket client simple example

Can someone please provide me very simple example of websocket client using javax.websocket? I want to connect to websocket (ws://socket.example.com:1234), send message (add channel) and listen to ...
Martin Ille's user avatar
  • 6,977
130 votes
5 answers
278k views

How to create websockets server in PHP

I am looking for a simple code to create a WebSocket server. I found phpwebsockets but it is outdated now and doesn't support the newest protocol. I tried updating it myself but it doesn't seem to ...
Dharman's user avatar
  • 32.5k
126 votes
9 answers
151k views

How to construct a WebSocket URI relative to the page URI?

I want to construct a WebSocket URI relative to the page URI at the browser side. Say, in my case convert HTTP URIs like http://example.com:8000/path https://example.com:8000/path to ws://example....
neuront's user avatar
  • 9,502
121 votes
5 answers
226k views

Is there a WebSocket client implemented for Python? [closed]

I found this project: http://code.google.com/p/standalonewebsocketserver/ for a WebSocket server, but I need to implement a WebSocket client in python, more exactly I need to receive some commands ...
diegueus9's user avatar
  • 30.8k
120 votes
2 answers
64k views

Differences between websockets and long polling for turn based game server

I am writing a server for an iOS game. The game is turn-based and the only time the server needs to push information to the client is to notify of the opponent's move. I am curious if anyone could ...
acidic's user avatar
  • 1,517
117 votes
13 answers
139k views

webSocketServer node.js how to differentiate clients

I am trying to use sockets with node.js, I succeded but I don't know how to differentiate clients in my code. The part concerning sockets is this: var WebSocketServer = require('ws').Server, wss ...
Ajouve's user avatar
  • 10.1k
114 votes
9 answers
62k views

Websocket API to replace REST API? [closed]

I have an application whose primary function works in real time, through websockets or long polling. However, most of the site is written in a RESTful fashion, which is nice for application s and ...
Harry's user avatar
  • 54.4k
114 votes
1 answer
38k views

Xmpp Vs Websocket [closed]

I'm about to develop a website that has near real time chat. I know that it can be implemented using xmpp or websocket protocols. I know also that the xmpp protocol has been developed in 1999 , and I ...
Khafaga's user avatar
  • 1,547
113 votes
5 answers
79k views

WebSockets ping/pong, why not TCP keepalive?

WebSockets have the option of sending pings to the other end, where the other end is supposed to respond with a pong. Upon receipt of a Ping frame, an endpoint MUST send a Pong frame in response, ...
Thomas's user avatar
  • 180k
110 votes
9 answers
111k views

Reconnection of Client when server reboots in WebSocket

I am using web socket using PHP5 and the Chrome browser as client. I have taken the code from the site http://code.google.com/p/phpwebsocket/. I run the server, and the client is also connected. I ...
siddhusingh's user avatar
  • 1,858
107 votes
12 answers
101k views

HTTP Authorization Header in EventSource (Server Sent Events)

I need to set an Authorization header to an HTML5 EventSource. As Server Sent Events seems to be disused since Websockets appeared, I cannot find any useful documentation. The approach I have already ...
Alvaro Luis Bustamante's user avatar
106 votes
5 answers
146k views

Sending message to a specific connected users using webSocket?

I wrote a code for broadcasting a message to all users: // websocket and http servers var webSocketServer = require('websocket').server; ... ... var clients = [ ]; var server = http.createServer(...
Royi Namir's user avatar
  • 147k
103 votes
3 answers
32k views

Faye vs. Socket.IO (and Juggernaut)

Socket.IO seems to be the most popular and active WebSocket emulation library. Juggernaut uses it to create a complete pub/sub system. Faye is also popular and active, and has its own javascript ...
John Bachir's user avatar
  • 22.9k
102 votes
6 answers
50k views

Will HTML5 allow web apps to make peer-to-peer HTTP connections?

Is it possible to create a web app that, with the help of a central server, could create direct connections with other users of the same web app? I'm imagining a process similar to UDP hole punching. ...
user avatar
101 votes
5 answers
176k views

Video streaming over websockets using JavaScript

What is the fastest way to stream live video using JavaScript? Is WebSockets over TCP a fast enough protocol to stream a video of, say, 30fps?
SMiLE's user avatar
  • 1,103

1
2 3 4 5
572