socket.IO can only connect one client (browser) at a time

I am having a problem of using socket IO to connect my server to the client(http website).

On the client, I have a button that when pressed, sends data to the server. However, this only works with one client.

If I have two clients, the first person to open the http website gets the socket IO connection, while the second person can open the page, but can't send any data to the server.

On the client side:

 var socket = new io.connect('ServerIP:8090');
 socket.on('message', function(obj){
       if ('buffer' in obj){
         //ignore this
    } else message(obj);
  });

On server side:

 var io = io.listen(server)
  , buffer = [];

io.on('connection', function(client)
 {

  client.send({ buffer: buffer });
  client.broadcast.send({ announcement: client.sessionId + ' connected' });

  chatGuests.push(client);

  client.on('message', function(message){
  var msg = { message: [client.sessionId, message] };
  buffer.push(msg);
  if (buffer.length > 15) buffer.shift();
  client.broadcast.send(msg);

 });

 client.on('disconnect', function(){
 client.broadcast.send({ announcement: client.sessionId + ' disconnected' });

 });

Instead of using client.broadcast.send(something) and client.send(something) use io.emit('eventName', something). Also, for setting up the server with the variable io use

var socket = require('socket.io');
var http = require('http');
var express = require('express');

var app = express();
var server = http.createServer(app);

var io = socket.listen(server);

And then after your code:

server.listen(8090);

This allows you to use the node.js module express, which allows additional communication between the client and server (but doesn't require you to rewrite your socket.io code).

For your client code, instead of using:

socket.on('message', function(obj){
//Do something
});

Use:

socket.on('eventName', function(something){
//Do something
});

This works for multiple kinds of data passing, not just messages. You can multiple event listeners to each do different things