Questions tagged [socket.io]

Socket.IO aims to make real-time apps possible in every browser and mobile device, blurring the differences between the different transport mechanisms. It supports multiple transports, such as WebSockets, Flash sockets, long polling, and more, automatically falling back when a transport fails.

Socket.IO is a Node.js package designed to make real-time applications possible and easy in every browser and mobile device. It supports the following transport mechanisms:

  • WebSockets
  • Adobe® Flash® Socket
  • AJAX long polling
  • AJAX multipart streaming
  • Forever Iframe
  • JSONP Polling

Socket.IO includes a JavaScript library that allows for easy programmatic communication with the server.

Some interesting Socket.IO features include:

  • Automatic JSON serialization
  • Namespacing connections over a single multiplexed connection
  • Volatile messages
  • Rooms (logically grouped connections)

API documentation can be found on the project's Wiki.

Useful Links:

20688 questions
62
votes
2 answers

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 weird issue: If I send a string constant to an…
sw.
  • 3,240
  • 2
  • 33
  • 43
62
votes
6 answers

Communicating with a socket.io server via c#

Is there a c# client that follows the socket.io protocol? I have a socket.io server that is communicating with a socket.io javascript client via a website, but i also need to connect a c# piece to it that can send and receive messages. Is there a…
Dested
  • 6,294
  • 12
  • 51
  • 73
62
votes
1 answer

List of Socket.io Events

Does anyone know what events are built-in in Socket.io? For example: connection, disconnect, join etc.
Abhishek Kaushik
  • 1,121
  • 1
  • 13
  • 17
62
votes
4 answers

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) { //users.push(socket); socket.on('message',…
Virushan
  • 723
  • 1
  • 7
  • 6
60
votes
5 answers

How to reconnect to websocket after close connection

I construct my websocket connection with this code (e.g.): var socket = new WebSocket("ws://94.12.176.177:8080"); And I close the connection with this one: socket.close(); But how do I reestablish connection? I've done some research and tried…
ket
  • 945
  • 1
  • 9
  • 15
60
votes
7 answers

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 soon as it's connected. Now I figured it would be…
Wingblade
  • 9,585
  • 10
  • 35
  • 48
59
votes
14 answers

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 clients connected to my server. The problem is after a…
imperium2335
  • 23,402
  • 38
  • 111
  • 190
58
votes
3 answers

How to use passport with express and socket.io?

I am currently trying to set up a basic authentication system for my node.js app. For now I am using express (3.0.0rc5), passport (0.1.12) and socket.io (0.9.10) with Mongoose as Store for session data. I have also been playing around with everyauth…
Patrick
  • 1,235
  • 1
  • 12
  • 15
57
votes
6 answers

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…
Zee
  • 8,420
  • 5
  • 36
  • 58
55
votes
3 answers

nodejs: Ajax vs Socket.IO, pros and cons

I thought about getting rid of all client-side Ajax calls (jQuery) and instead use a permanent socket connection (Socket.IO). Therefore I would use event listeners/emitters client-side and server-side. Ex. a click event is triggered by user in the…
ezmilhouse
  • 8,933
  • 7
  • 29
  • 38
55
votes
4 answers

socket.io - how to broadcast messages on a namespace?

According to socket.io examples: To broadcast, simply add a broadcast flag to emit and send method calls. Broadcasting means sending a message to everyone else except for the socket that starts it. var io =…
JustAMartin
  • 13,165
  • 18
  • 99
  • 183
55
votes
4 answers

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 tries to support older browsers, so it starts a…
ItalyPaleAle
  • 7,185
  • 6
  • 42
  • 69
54
votes
2 answers

Is socket.io emit callback appropriate?

Recently I have been messing around with socket.io and found this interesting thing, that I can have emit function callback like this. I start emitting on client side like this: client.emit('eventToEmit', dataToEmit, function(error, message){ …
antanas_sepikas
  • 5,644
  • 4
  • 36
  • 67
53
votes
11 answers

node.js /socket.io/socket.io.js not found

i keep on getting the error /socket.io/socket.io.js 404 (Not Found) Uncaught ReferenceError: io is not defined my code is var express = require('express'), http = require('http'); var app = express(); var server = http.createServer(app); var io =…
hausinho
  • 549
  • 1
  • 4
  • 8
53
votes
8 answers

Node.js: socket.io close client connection

How can I close the socket connection on the client side? I am using: socket.io 0.9 node.js 0.10.15 express 3.3.4 i.e.: call localhost/test -- server side var test = io .of('/test') .on('connection', function (socket) { console.log('open…
baam
  • 1,122
  • 2
  • 14
  • 25