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
2,495
questions
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
...
1212
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 ...
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 ...
399
votes
18
answers
478k
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 ...
92
votes
13
answers
114k
views
How can I send and receive WebSocket messages on the server side?
How can I send and receive messages on the server side using WebSocket, as per the protocol?
Why do I get seemingly random bytes at the server when I send data from the browser to the server? It the ...
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?
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 ...
30
votes
3
answers
27k
views
Real time updates from database using JSF/Java EE
I have one application running in the following environment.
GlassFish Server 4.0
JSF 2.2.8-02
PrimeFaces 5.1 final
PrimeFaces Extension 2.1.0
OmniFaces 1.8.1
EclipseLink 2.5.2 having JPA 2.1
MySQL 5....
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 ...
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, ...
145
votes
8
answers
411k
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....
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. ...
36
votes
3
answers
177k
views
How to make cross domain request [duplicate]
As you know, the security of the web browser disallows making of cross domain requests. I read a book which says that you should use XMLHTTPRequest only if you can put the files on the server (means ...
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 ...
273
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.
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/...
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 ...
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:
...
50
votes
6
answers
63k
views
Accessing HttpSession from HttpServletRequest in a Web Socket @ServerEndpoint
Is it possible to get the HttpServletRequest inside a @ServerEndpoint? Primarily I am trying to get it so I can access the HttpSession object.
3
votes
1
answer
6k
views
How to avoid blocking the asyncio event loop with looping functions
I'm using FastAPI with WebSockets to "push" SVGs to the client. The problem is: If iterations run continuously, they block the async event loop and the socket therefore can't listen to other ...
695
votes
12
answers
334k
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 ...
86
votes
3
answers
215k
views
How to Use Sockets in JavaScript\HTML? [closed]
How to Use Sockets in JavaScript\HTML?
May be using some cool HTML5?
Libraries?
Tutorials?
Blog Articles?
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 ...
84
votes
2
answers
70k
views
Is native PHP support for Web Sockets available?
Looking for Hello World Type Example of Web Sockets Implementation:
Here is Socket Create reference from php.net but this looks more low level than Web Sockets.
I want to use this Web Sockets as ...
58
votes
4
answers
98k
views
Check if my website is open in another tab
I want to check with JavaScript if the user has already opened my website in another tab in their browser.
It seems I cannot do that with pagevisibility...
The only way I see is to use WebSocket ...
138
votes
4
answers
205k
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://...
2
votes
2
answers
3k
views
WebSockets in FastAPI - ConnectionClosedOK: received 1000 (OK)
I have 3 clients, who periodically send data to my server. I use the example from FastAPI's documentation.
This is my server code:
class ConnectionManager:
def __init__(self):
self....
63
votes
3
answers
75k
views
Websocket server: onopen function on the web socket is never called
I'm trying to implement a C# web socket server, but its giving me a few troubles.
I'm running a webserver(ASP.NET) to host the page with the javascript and the web socket server is implemented as a C# ...
44
votes
4
answers
41k
views
HAProxy + WebSocket Disconnection
I am using HAProxy to send requests, on a subdomain, to a node.js app.
I am unable to get WebSockets to work. So far I have only been able to get the client to establish a WebSocket connection but ...
14
votes
1
answer
14k
views
Ajax vs Socket.io
I am developing a web app and I was wondering which method should be suitable for my project.
Basically what I want to display to the users are some notifications which are taken from requests to ...
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 ...
92
votes
5
answers
63k
views
Do websockets allow for p2p (browser to browser) communication?
To clarify when I ask about browser to browser communication I mean without a server in between forwarding message. I would like to implement something like this for a game. If p2p in websockets isn'...
36
votes
4
answers
46k
views
How to maintain a WebSockets connection between pages?
On one of my scripts I have this code:
var webSocket = window.WebSocket || window.MozWebSocket;
window.ws = new webSocket('ws://64.121.210.140:2585/consoleappsample', 'my-protocol');
Which works ...
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 ...
84
votes
5
answers
78k
views
Websocket Authentication and Authorization in Spring
I've been struggling a lot to properly implement Stomp (websocket) Authentication and Authorization with Spring-Security. For posterity i'll answer my own question to provide a guide.
The Problem
...
46
votes
9
answers
53k
views
php ratchet websocket SSL connect?
I have a ratchet chat server file
use Ratchet\Server\IoServer;
use Ratchet\WebSocket\WsServer;
use MyAppChat\Chat;
require dirname(__DIR__) . '/vendor/autoload.php';
$server = IoServer::factory(
...
41
votes
1
answer
26k
views
websocket vs rest API for real time data? [closed]
I need to constantly access a server to get real time data of financial instruments. The price is constantly changing so I need to request new prices every 0.5 seconds. The REST APIs of the brokers ...
55
votes
4
answers
66k
views
Socket.io 1.x: use WebSockets only?
We are developing a web application that will run only on modern browsers (IE10+) for different reasons.
One of the features we implemented is Socket.io 1.x. However, by default the Socket.io client ...
50
votes
3
answers
22k
views
Differences between ZeroMQ and WebSockets
I'd like to know what the differences are between the ZeroMQ and WebSockets protocols. I know WebSockets was designed for web browser clients, but I'm assuming it can also be used server to server. ...
13
votes
1
answer
5k
views
Moving from socket.io to raw websockets?
Right now I'm using socket.io with mandatory websockets as the transport. I'm thinking about moving to raw websockets but I'm not clear on what functionality I will lose moving off of socket.io. ...
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 ...
88
votes
9
answers
114k
views
How do I run Node.js on port 80?
My aim is to run Node.js on port 80. This is because I am finding node.js is being blocked from certain networks which do not allow traffic from any other port.
It appears that the best way to do ...
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 ...
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 ...
9
votes
3
answers
12k
views
How to (de)construct data frames in WebSockets hybi 08+?
Since Chrome updated to v14, they went from version three of the draft to version eight of the draft.
I have an internal chat application running on WebSocket, and although I've gotten the new ...
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 ...
78
votes
6
answers
70k
views
JSON Web Token (JWT) with Spring based SockJS / STOMP Web Socket
Background
I am in the process of setting up a RESTful web application using Spring Boot (1.3.0.BUILD-SNAPSHOT) that includes a STOMP/SockJS WebSocket, which I intend to consume from an iOS app as ...
15
votes
1
answer
8k
views
How do I access instantiated WebSockets in Jetty 9?
This is probably obvious, but I am new to this paradigm. I create a Jetty Server and register my websocket class as follows:
Server server = new Server(8080);
WebSocketHandler ...
15
votes
3
answers
9k
views
Inspecting WebSocket frames in an undetectable way
How I can read WebSocket frames of a web page in a Chrome extension or Firefox add-on, in a way that cannot be detected by the page?
Inspect WebSockets frames from a Chrome Dev Tools extension ...
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. ...