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.

websocket
Filter by
Sorted by
Tagged with
1214 votes
8 answers
331k 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.4k
1189 votes
4 answers
215k 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.6k
695 votes
12 answers
335k 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,208
453 votes
3 answers
247k 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
  • 47.7k
451 votes
6 answers
204k 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.1k
447 votes
10 answers
153k 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
  • 11.9k
399 votes
18 answers
479k 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
305 votes
8 answers
153k 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,746
287 votes
6 answers
193k 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,903
277 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,787
274 votes
12 answers
352k 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
  • 22.8k
245 votes
12 answers
354k 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
110k 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
222 votes
2 answers
188k 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,761
217 votes
4 answers
68k 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,866
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.5k
197 votes
2 answers
150k 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
252k 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
187 votes
6 answers
176k 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
12 answers
242k 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
  • 19.7k
184 votes
4 answers
188k 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.3k
180 votes
2 answers
87k 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,865
176 votes
5 answers
95k 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,781
171 votes
5 answers
47k 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
6 answers
194k 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,926
156 votes
4 answers
54k 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,240
153 votes
3 answers
103k 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,309
145 votes
8 answers
412k 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,272
144 votes
3 answers
76k 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,157
143 votes
7 answers
228k 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
  • 30.8k
138 votes
4 answers
206k 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.2k
138 votes
2 answers
109k 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
213k 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
  • 43.8k
129 votes
3 answers
68k 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
129 votes
6 answers
310k 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,897
128 votes
5 answers
275k 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
  • 32k
125 votes
9 answers
147k 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,442
120 votes
2 answers
63k 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
119 votes
5 answers
221k 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.4k
117 votes
13 answers
135k 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
  • 9,961
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
  • 53.9k
114 votes
1 answer
37k 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
77k 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
  • 178k
110 votes
9 answers
109k 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,857
106 votes
5 answers
143k 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.6k
103 votes
11 answers
92k 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
100 votes
3 answers
150k views

Websocket onerror - how to read error description?

I've been developing browser-based multi player game for a while now and I've been testing different ports accessibility in various environment (client's office, public wifi etc.). All is going quite ...
Siniša's user avatar
  • 3,058
100 votes
5 answers
268k views

Creating a "Hello World" WebSocket example

I don't understand why I cannot make the following code work. I want to connect with JavaScript to my server console application. And then send data to the server. Here is the server code: ...
Tono Nam's user avatar
  • 35.1k

1
2 3 4 5
568