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
42
votes
6 answers

SocketIO ERR_CONNECTION_REFUSED

I am starting to use NodeJS and Socket.IO. I am trying to set up a basic example with a NodeJS http server and establish a Socket.IO connection to the server. I am also using angular JS and basically what I want is that when a user presses a button…
tampeta
  • 541
  • 2
  • 5
  • 7
42
votes
3 answers

How much data can I send through a socket.emit?

So I am using node.js and socket.io. I have this little program that takes the contents of a text box and sends it to the node.js server. Then, the server relays it back to other connected clients. Kind of like a chat service but not…
cbmeeks
  • 11,248
  • 22
  • 85
  • 136
41
votes
5 answers

Can I upload a file to server by socket.io in node.js?

I have a socket.io client to whom socket.io server is listening in node.js. I want to upload a file to server by socket.io. because my socket.io client is under apache. and socket.io server is in Node.js. I want to code uploading of file in Node.js.…
XMen
  • 29,384
  • 41
  • 99
  • 151
41
votes
1 answer

Acknowledgment for socket.io custom event

I am looking for a method to acknowledge a socket.emit call. socket.emit('message', msg); I have seen a mechanism where the receiver would send another custom event as an acknowledgement, but this would add thousands of transports in my chat…
Vipin Kp
  • 422
  • 1
  • 5
  • 8
41
votes
6 answers

Authorizing and handshaking with Socket.IO

I'm wondering what the main function of authorization and the handshake in Socket.IO is. I've already read their wiki and authorizing guide on GitHub but I still don't understand the following: How does the authorization work in Socket.io? What is…
Joenel de Asis
  • 1,401
  • 3
  • 15
  • 14
41
votes
11 answers

socket.io - ReferenceError: io is not defined

I am writing an application for Android 2.3.5 (that will also be compatible with iOS). I wish to transfer data from the app's HTML/Javascript to a Python program on a server (which uses the Twisted engine to retrieve the data). I've tried many…
Ness
  • 1,415
  • 1
  • 13
  • 19
40
votes
2 answers

List of connected clients username using socket io

I've made a chat client with different chat rooms in NodeJS, socketIO and Express. I am trying to display an updated list over connected users for each room. Is there a way to connect a username to an object so I could see all the usernames when I…
kimpettersen
  • 1,602
  • 2
  • 13
  • 18
40
votes
1 answer

Advantage/disadvantage of using socketio heartbeats

Socket.io allows you to use heartbeats to "check the health of Socket.IO connections." What exactly are heartbeats and why should or shouldn't I use them?
jhchen
  • 14,355
  • 14
  • 63
  • 91
40
votes
5 answers

How to reuse redis connection in socket.io?

Here is my code using socket.io as WebSocket and backend with pub/sub redis. var io = io.listen(server), buffer = []; var redis = require("redis"); var subscribe = redis.createClient(); **<--- open new connection…
user717166
  • 690
  • 2
  • 10
  • 17
40
votes
4 answers

WebSockets over a 3G connection

I've been playing with Socket.io, node.js and WebSockets, all of which I can get working fine over a wifi connection. However, when I test out a WebSocket-enabled app over a 3G connection (on my iPhone, for example) then it seems like falling back…
suttree
  • 1,303
  • 2
  • 10
  • 8
40
votes
4 answers

Can I access a cookie from Socket.io?

I want to set some user information in a cookie and be able to access it on connection, is this possible?
Dan
  • 2,649
  • 4
  • 26
  • 22
40
votes
9 answers

socket.io, 'Access-Control-Allow-Origin' error

I have set up a node server with socket io turning and trying to connect to it through another server. However some browsers on different computers give me this error and makes it reconnect the whole time: XMLHttpRequest cannot load…
lolplayer101
  • 2,112
  • 2
  • 17
  • 26
40
votes
5 answers

Socket.io error hooking into express.js

I'm trying to hook socket.io and express.js together: var socket = require('./socket_chat/socket.js'); var express = require('express'), app = module.exports.app = express(); var io = require('socket.io').listen(app); …
alyx
  • 2,593
  • 6
  • 39
  • 64
40
votes
9 answers

Error: Cannot find module 'socket.io'

[~]# node node.js Error: Cannot find module 'socket.io' [~]# node -v v0.10.10 socket.io installed: npm install socket.io npm WARN package.json policyfile@0.0.4 No repository field. npm WARN package.json policyfile@0.0.4 'repositories' (plural)…
DmitriyB
  • 413
  • 1
  • 4
  • 6
40
votes
7 answers

socket.io - 'connect' event does not fire on the client

I am trying to get started with node.js and socket.io. I have a very (very) simple client-server test application and i can't get it to work. The system is set up on a windows machine with an apache server. The apache is running on port 81 and the…
kfiroo
  • 1,913
  • 2
  • 15
  • 18