All Questions

Tagged with
Filter by
Sorted by
Tagged with
695 votes
12 answers
336k 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
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
  • 47.8k
275 votes
12 answers
143k views

Send response to all clients except sender

To send something to all clients, you use: io.sockets.emit('response', data); To receive from clients, you use: socket.on('cursor', function(data) { ... }); How can I combine the two so that ...
switz's user avatar
  • 24.8k
245 votes
13 answers
355k 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
225 votes
17 answers
280k views

node.js TypeError: path must be absolute or specify root to res.sendFile [failed to parse JSON]

[add] So my next problem is that when i try adding a new dependence (npm install --save socket.io). The JSON file is also valid. I get this error: Failed to parse json npm ERR! Unexpected string npm ...
IE8IsBetterThenGoogleChrome's user avatar
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
205 votes
35 answers
340k views

How do I get a list of connected sockets/clients with Socket.IO?

I'm trying to get a list of all the sockets/clients that are currently connected. io.sockets does not return an array, unfortunately. I know I could keep my own list using an array, but I don't think ...
Andy Hin's user avatar
  • 30.9k
193 votes
8 answers
72k views

socket.io rooms or namespacing?

I am investigating nodejs/socket.io for real time chat, and I need some advice for implementing rooms. Which is better, using namespace or using the room feature to completely isolate grops of ...
Joseph's user avatar
  • 3,145
190 votes
13 answers
253k 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
175 votes
7 answers
240k views

socket.emit() vs. socket.send()

What's the difference between these two? I noticed that if I changed from socket.emit to socket.send in a working program, the server failed to receive the message, although I don't understand why. ...
node ninja's user avatar
  • 32.4k
174 votes
4 answers
188k views

Authenticating socket io connections using JWT

How can I authenticate a socket.io connection? My application uses a login endpoint from another server (python) to get a token, how can I get use that token whenever a user opens a socket connection ...
el_pup_le's user avatar
  • 11.9k
164 votes
31 answers
302k views

Socket.io + Node.js Cross-Origin Request Blocked

I'm using node and socket.io to write a chat application. It works fine on Chrome but mozilla gives an error to enable the Cross-Origin Requests. Cross-Origin Request Blocked: The Same Origin ...
Waleed Ahmad's user avatar
  • 2,244
151 votes
22 answers
189k views

Get the client's IP address in socket.io

When using socket.IO in a Node.js server, is there an easy way to get the IP address of an incoming connection? I know you can get it from a standard HTTP connection, but socket.io is a bit of a ...
Toji's user avatar
  • 34.2k
136 votes
14 answers
214k 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.1k
135 votes
7 answers
143k views

Node.js client for a socket.io server

I have a socket.io server running and a matching webpage with a socket.io.js client. All works fine. But, I am wondering if it is possible, on another machine, to run a separate node.js application ...
Predrag Stojadinović's user avatar
134 votes
7 answers
86k views

Socket.IO Authentication

I am trying to use Socket.IO in Node.js, and am trying to allow the server to give an identity to each of the Socket.IO clients. As the socket code is outside the scope of the http server code, it ...
Ryan's user avatar
  • 2,102
125 votes
5 answers
191k views

What is an example of the simplest possible Socket.io example?

So, I have been trying to understand Socket.io lately, but I am not a supergreat programmer, and almost every example I can find on the web (believe me I have looked for hours and hours), has extra ...
Cocorico's user avatar
  • 2,339
122 votes
8 answers
160k views

How to send a message to a particular client with socket.io

I'm starting with socket.io + node.js, I know how to send a message locally and to broadcast socket.broadcast.emit() function:- all the connected clients receive the same message. Now, I would like ...
Nizar B.'s user avatar
  • 3,128
122 votes
5 answers
82k views

Socket.io rooms difference between broadcast.to and sockets.in

Socket.io's readme contains the following example: var io = require('socket.io').listen(80); io.sockets.on('connection', function (socket) { socket.join('justin bieber fans'); ...
knex's user avatar
  • 1,753
118 votes
4 answers
100k views

What's the difference between io.sockets.emit and broadcast?

What's the difference between io.sockets.emit and socket.broadcast.emit? Is it only that broadcast emits to everyone BUT the socket that sends it? It seems like they can be used interchangeably: io....
swiecki's user avatar
  • 3,483
110 votes
2 answers
46k views

How to remove debugging from an Express app?

I would like to remove the debugging mode. I am using express, redis, socket.io and connect-redis, but I do not know where the debugging mode comes from. Someone has an idea?
Vsplit's user avatar
  • 1,988
101 votes
11 answers
103k views

socket.io and session?

I'm using express framework. I want to reach session data from socket.io. I tried express dynamicHelpers with client.listener.server.dynamicViewHelpers data, but i can't get session data. Is there a ...
sfs's user avatar
  • 1,153
100 votes
7 answers
57k views

How to share sessions with Socket.IO 1.x and Express 4.x?

How can I share a session with Socket.io 1.0 and Express 4.x? I use a Redis Store, but I believe it should not matter. I know I have to use a middleware to look at cookies and fetch session, but don't ...
Mustafa's user avatar
  • 10.2k
99 votes
7 answers
96k views

Send additional data on socket connection

How to best send additional data upon socket connection? Client: socket.on('connect',function(){ //I'd like set some values and pass them up to the node server. }); Node.js Server: io.on('...
Dan's user avatar
  • 2,729
97 votes
3 answers
88k views

How to integrate nodeJS + Socket.IO and PHP?

I have recently been looking around, to find a good way to communicate between nodeJS and PHP. Here is the idea : nodeJS is still quite new, and it can be kind of tricky to develop a full application ...
Jérémy Dutheil's user avatar
96 votes
22 answers
460k views

WebSocket connection failed: Error during WebSocket handshake: Unexpected response code: 400

I am trying to integrate Socket.io with Angular and I'm having difficulties making a connection from the client-side to the server. I've looked through other related questions but my issue is ...
ashe540's user avatar
  • 2,141
95 votes
8 answers
68k views

Using socket.io in Express 4 and express-generator's /bin/www

So here is the deal: I'm trying to use socket.io in an express project. After Express Js 4 was lauched, i've updated my express-generator and now the app initial functions goes into ./bin/www file, ...
user1576978's user avatar
  • 1,755
94 votes
6 answers
182k views

Get connection status on Socket.io client

I'm using Socket.io, and I'd like to know the status of connection to the server from the client-side. Something like this: socket.status // return true if connected, false otherwise I need this ...
franzlorenzon's user avatar
92 votes
8 answers
43k views

Websocket transport reliability (Socket.io data loss during reconnection)

Used NodeJS, Socket.io Problem Imagine there are 2 users U1 & U2, connected to an app via Socket.io. The algorithm is the following: U1 completely loses Internet connection (ex. switches ...
igorpavlov's user avatar
  • 3,586
84 votes
6 answers
91k views

Update all clients using Socket.io?

Is it possible to force all clients to update using socket.io? I've tried the following, but it doesn't seem to update other clients when a new client connects: Serverside JavaScript: I'm attempting ...
Jack's user avatar
  • 15.8k
83 votes
2 answers
41k views

RabbitMQ vs Socket.io? [closed]

I'm doing real time live web app development. Browser users should be able to communicate with eachother through a node.js server. One of the user writes a message and all other users will get it. I ...
ajsie's user avatar
  • 78.8k
79 votes
4 answers
47k views

io.emit vs socket.emit

I'm new to socket.io and have run in to something that seems pretty weird. I don't actually know the difference between socket.emit and io.emit but I can't find an explanation anywhere. io.on('...
Manu Masson's user avatar
  • 1,727
78 votes
4 answers
53k views

Separating file server and socket.io logic in node.js

I'm fairly new to node.js and I've found its quite complicated separating a project into multiple files as the project grows in size. I had one large file before which served as both a file server and ...
stevendesu's user avatar
  • 16.3k
77 votes
1 answer
137k views

Creating Rooms in Socket.io

I would like to ask for your help. I'm having a hard time in my client side of socket.io, I would like to call this code in my client side to create a room in socket.io: var rooms = []; socket.on('...
Joenel de Asis's user avatar
76 votes
8 answers
40k views

Where is the socket.io client library?

As far as I have seen, there is no explanation as to where we are to locate the client side script for socket.io if node.js is not used as the web server. I've found a whole directory of client side ...
Braun Shedd's user avatar
75 votes
9 answers
149k views

nodejs: listen EACCES: permission denied 0.0.0.0:80

I am trying to create https server to test socket io by node js. According this page openssl genrsa -out privatekey.pem 2048 openssl req -new -key privatekey.pem -out certrequest.csr openssl x509 -...
Cyrus the Great's user avatar
75 votes
3 answers
75k views

Node.js EMFILE error with increasing traffic

I have very recently received a lot of traffic to my site that runs Node.js. With the increasing traffic it has started to crash a lot, which has not happened before. I get the following error in my ...
codekick's user avatar
  • 753
75 votes
2 answers
23k views

how does socket.io work? [closed]

I am using socket.io and it was quick to setup (thanks to examples on their usage page) but i'd like to find out more about what exactly is going on under covers and what's the technology that makes ...
Sonic Soul's user avatar
  • 24.4k
72 votes
4 answers
59k views

Scaling Socket.IO to multiple Node.js processes using cluster

Tearing my hair out with this one... has anyone managed to scale Socket.IO to multiple "worker" processes spawned by Node.js's cluster module? Lets say I have the following on four worker processes (...
Lee Benson's user avatar
  • 11.4k
72 votes
6 answers
55k views

Unit testing Node.js and WebSockets (Socket.io)

Could anyone provide a rock-solid, dead-simple unit test for Node.js using WebSockets (Socket.io)? I'm using socket.io for Node.js, and have looked at socket.io-client for establishing the client ...
mysterlune's user avatar
  • 1,711
69 votes
3 answers
54k views

How to connect two node.js servers with websockets?

Here's my problem: I have server A, running node.js and using socket.io for communicating with clients (web browsers). This all is running fine and dandy. However, now that I have server B, which ...
crappish's user avatar
  • 2,698
68 votes
4 answers
31k views

What's the difference between engine.io and socket.io?

Regarding node.js, I'm using socket.io for real-time socket connection from the client application to the server application. I just heard about engine.io. Is engine.io a replacement for socket.io? I ...
L N's user avatar
  • 2,958
68 votes
1 answer
29k views

Node.js, Socket.io, Redis pub/sub high volume, low latency difficulties

When conjoining socket.io/node.js and redis pub/sub in an attempt to create a real-time web broadcast system driven by server events that can handle multiple transports, there seems to be three ...
lebear's user avatar
  • 689
67 votes
9 answers
125k views

socket.io-client how to set request header when making connection

I'm trying to set a http header when socket.io client makes the connection request. Is there a way to do this? Here is what i'm doing: // server side var io = socketio(server); io.use(function (...
Ziyu's user avatar
  • 1,087
63 votes
1 answer
73k views

List of Socket.io Events

Does anyone know what events are built-in in Socket.io? For example: connection, disconnect, join etc.
Abhishek Kaushik's user avatar
63 votes
4 answers
39k views

How to protect against distributed denial-of-service attacks in Node.js with Socket.io?

I have been learning node.js and socket.io lately. My question is how can I protect server against client side attacks? This is my server code io.sockets.on('connection', function (socket) { //...
Virushan's user avatar
  • 733
62 votes
14 answers
97k views

Socket.IO Connected User Count

I finally got Socket.IO to work properly, but I have encountered a strange problem. I am not sure if this is the best way, but I am using: io.sockets.clients().length This returns the number of ...
imperium2335's user avatar
  • 23.8k
62 votes
2 answers
4k views

Socket.IO issue with control chars

I am implementing an application that uses websockets and a console accessed via Telnet. There is a communication between the connection established via websockets and the console. I am experiencing a ...
sw.'s user avatar
  • 3,250
61 votes
7 answers
75k views

Send custom data along with handshakeData in socket.io?

So I have an application running node js with socket.io as a backend and normal javascript as frontend. My application has a login system which currently simply has the client send its login data as ...
Wingblade's user avatar
  • 9,835
57 votes
6 answers
106k views

How to resolve a Socket.io 404 (Not Found) error?

I am using Socket.io with Express. In my project I have a login page and a home page. When I do successful login, I navigate to localhost:3000/home where I get this error: GET http://localhost:3000/...
Zee's user avatar
  • 8,460

1
2 3 4 5
266