socketio

socketio

Member Since 6 years ago

Automattic

Experience Points
0
follower
Lessons Completed
0
follow
Best Reply Awards
40
repos
Activity
Oct
23
21 hours ago
Activity icon
fork

cooliodev1 forked socketio/chat-example

⚡ Basic chat example with Socket.IO
cooliodev1 MIT License Updated
fork time in 9 minutes ago
started
started time in 4 hours ago
Activity icon
issue

sebamarynissen issue comment socketio/socket.io

sebamarynissen
sebamarynissen

fix: fix race conditions with dynamic namespaces (#4136)

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

A race condition exists when creating dynamic namespaces (see #4136)

New behavior

The race condition is fixed.

sebamarynissen
sebamarynissen

I've changed the test a bit so that it does not rely on setTimeout(), hereby ensuring that the race condition is definitely present.

Activity icon
issue

plusl894860970 issue socketio/socket.io-admin-ui

plusl894860970
plusl894860970

Can egg-socket.io be supported

I tried this, but it didn't work. instrument(this.app.io, { namespaceName: 'admin', auth: false });

Activity icon
fork

frozeeen forked socketio/socket.io-admin-ui

⚡ Admin UI for Socket.IO
frozeeen MIT License Updated
fork time in 12 hours ago
started
started time in 12 hours ago
started
started time in 15 hours ago
started
started time in 16 hours ago
Activity icon
issue

naseemkullah issue socketio/socket.io

naseemkullah
naseemkullah

feature request: middleware for emitted events

Is your feature request related to a problem? Please describe. I'd like to perform some logic for every emitted event (log them).

Describe the solution you'd like An option to perform some logic within emit, after the event is emitted but just before emit returns true.

Describe alternatives you've considered overriding emit as per https://stackoverflow.com/questions/8832414/overriding-socket-ios-emit-and-on

started
started time in 17 hours ago
started
started time in 19 hours ago
started
started time in 20 hours ago
Oct
22
1 day ago
Activity icon
fork

renowncoder forked socketio/socket.io-redis-adapter

⚡ Adapter to enable broadcasting of events to multiple separate socket.io server nodes.
renowncoder MIT License Updated
fork time in 22 hours ago
Activity icon
fork

MaatheusGois forked socketio/socket.io-client-swift

fork time in 22 hours ago
Activity icon
issue

ylcinyakup issue socketio/socket.io-client-java

ylcinyakup
ylcinyakup

cant set HandShake message

I want to connect v2 socketIo server. in javascript i receive data but i cant receive data with java. because i cant send custom handshake message.. can you help we with this issue ?

Socket.IO server version: v2

Socket.IO java client version: 1.0.1

Client


String handshake = "sample";
try {
            IO.Options options = new IO.Options();
            Socket socket = IO.socket(new URI(url), options);
            socket.connect();

            socket.on(Socket.EVENT_CONNECT, args12 -> System.out.println("connected"));
            socket.on(Socket.EVENT_CONNECT_ERROR, args13 -> System.out.println("connection error"));
            
            boolean connected = socket.connected();
            while (!connected) {
                Thread.sleep(1000);
                connected = socket.connected();
            }
            socket.send("handshake", handshake);
            socket.emit("handshake", handshake);
            socket.on("topic1", args1 -> System.out.println("topic1"));
            socket.on("topic2", args1 -> System.out.println("topic2"));
            boolean cn = socket.hasListeners("cn");
            boolean cs = socket.hasListeners("cs");
            while (true) {

                connected = socket.connected();
                System.out.println("asdasd" + connected);
                Thread.sleep(1000);

            }


Expected behavior connection success but never get a message. Because i cant send custom handshake message.

Activity icon
issue

bnsy issue comment socketio/socket.io-client-swift

bnsy
bnsy

Transports property of configuration options in Android?

In the android client SDK, we have a transports property in a configuration like this

IO.Options opts = new IO.Options();
opts.transports = new String[]{WebSocket.NAME, Polling.NAME};

It helps you to prioritize first WebSocket and then pooling. But I coulnd't find in ios SDK something similar like this parameter.

We have only,

forcePolling(:) forceWebsockets(:)

from here docs

Is there any parameter which could be acting like prioritization? Thanks a lot.

bnsy
bnsy

How to set

transports: ['websocket'] in swift @nuclearace

started
started time in 1 day ago
pull request

naseemkullah pull request socketio/socket.io

naseemkullah
naseemkullah

fix: event type for use()

make it same as others (first element is eventName)

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

New behavior

Other information (e.g. related issues)

Activity icon
fork

naseemkullah forked socketio/socket.io

⚡ Realtime application framework (Node.JS server)
naseemkullah MIT License Updated
fork time in 1 day ago
Activity icon
issue

sebamarynissen issue comment socketio/socket.io

sebamarynissen
sebamarynissen

Race condition with dynamic namespaces

I have noticed that a race condition exists with dynamic namespaces. Consider the following setup

// Server side
import { Server } from 'socket.io';
const io = new Server(3000, {});

io.of(async (nsp, auth, next) => {
  let exists = !!await queryDatabaseForResource({});
  next(null, exists);
});

If the query to the database takes some time and a lot of clients are trying to connect to the same namespace in a short period of time, the namespace will be created multiple times. This will result in sockets being connected to a namespace that is overridden by another one, and hence they will no longer be receiving events.

Looking at Server.prototype._checkNamespace, I think this can be solved as follows:

Server.prototype._checkNamespace = function(name, auth, fn) {
  if (this.parentNsps.size === 0) return fn(false);
  const keysIterator = this.parentNsps.keys();
  const run = () => {
    const nextFn = keysIterator.next();
    if (nextFn.done) return fn(false);
    nextFn.value(name, auth, (err, allow) => {
      if (err || !allow) {
        run();
      } else if (this._nsps.has(name)) {

        // If the namespace has been created in the meantime, do not create it again.
        return fn(this._nsps.get(name));

      } else {

        const namespace = this.parentNsps
          .get(nextFn.value)
          .createChild(name);

        this.sockets.emitReserved('new_namespace', namespace);
        fn(namespace);

      }
    });
  };
  run();
};

I will file a PR to solve this.

Context

The odds of this race condition happening are obviously rather low, but I experienced them on a website of mine where I organize tournaments. If the tournament starts, people are all sent to a socket.io namespace where their match is hosted. These namespaces are created dynamically, and so it happens that a large amount of people tries to connect at the same moment.

pull request

sebamarynissen pull request socketio/socket.io

sebamarynissen
sebamarynissen

fix: fix race conditions with dynamic namespaces (#4136)

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

A race condition exists when creating dynamic namespaces (see #4136)

New behavior

The race condition is fixed.

Activity icon
fork

aquelegustavo forked socketio/socket.io-website

⚡ Socket.IO website and blog
aquelegustavo Updated
fork time in 1 day ago
started
started time in 1 day ago
Activity icon
issue

sebamarynissen issue socketio/socket.io

sebamarynissen
sebamarynissen

Race condition with dynamic namespaces

I have noticed that a race condition exists with dynamic namespaces. Consider the following setup

// Server side
import { Server } from 'socket.io';
const io = new Server(3000, {});

io.of(async (nsp, auth, next) => {
  let exists = !!await queryDatabaseForResource({});
  next(null, exists);
});

If the query to the database takes some time and a lot of clients are trying to connect to the same namespace in a short period of time, the namespace will be created multiple times. This will result in sockets being connected to a namespace that is overridden by another one, and hence they will no longer be receiving events.

Looking at Server.prototype._checkNamespace, I think this can be solved as follows:

Server.prototype._checkNamespace = function(name, auth, fn) {
  if (this.parentNsps.size === 0) return fn(false);
  const keysIterator = this.parentNsps.keys();
  const run = () => {
    const nextFn = keysIterator.next();
    if (nextFn.done) return fn(false);
    nextFn.value(name, auth, (err, allow) => {
      if (err || !allow) {
        run();
      } else if (this._nsps.has(name)) {

        // If the namespace has been created in the meantime, do not create it again.
        return fn(this._nsps.get(name));

      } else {

        const namespace = this.parentNsps
          .get(nextFn.value)
          .createChild(name);

        this.sockets.emitReserved('new_namespace', namespace);
        fn(namespace);

      }
    });
  };
  run();
};

I will file a PR to solve this.

Context

The odds of this race condition happening are obviously rather low, but I experienced them on a website of mine where I organize tournaments. If the tournament starts, people are all sent to a socket.io namespace where their match is hosted. These namespaces are created dynamically, and so it happens that a large amount of people tries to connect at the same moment.

started
started time in 1 day ago
started
started time in 1 day ago
Previous