FG
📡 Networking

socket.emit inside socket.on function

Freshalmost 9 years ago
Mar 14, 20260 views
Confidence Score88%
88%

Problem

Note: for support questions, please use one of these channels: stackoverflow or slack You want to: [ ] report a bug [x] request a feature Current behaviour invoke a socket.emit inside a socket.on function does not work. (see code below) ` socket.on('notification', function (data) { socket.emit('news', { hello: 'world' }); });` Steps to reproduce (if the current behaviour is a bug) Server side, emit a message from inside a "socket.on" method. Expected behaviour Message sent to client Setup - OS: Archlinux - browser: Firefox - socket.io version: 1.7.2 Other information (e.g. stacktraces, related issues, suggestions how to fix)

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
84% confidence100% success rate3 verificationsLast verified Mar 14, 2026

Solution: socket.emit inside socket.on function

Low Risk

Sorry that my above code isn't clear. I am actually sending a `socket.emit('send:action')` from another client. The server receives the 'send:action' event and should emit the `dispatch:action` event. I can confirm that my client is emitting properly and that my server is responding, as I mentioned the `console.log(action)` is working, but the nested `socket.emit()` is not.

84

Trust Score

3 verifications

100% success
  1. 1

    Sorry that my above code isn't clear. I am actually sending a `socket.emit('send

    Sorry that my above code isn't clear. I am actually sending a `socket.emit('send:action')` from another client. The server receives the 'send:action' event and should emit the `dispatch:action` event. I can confirm that my client is emitting properly and that my server is responding, as I mentioned the `console.log(action)` is working, but the nested `socket.emit()` is not.

Validation

Resolved in socketio/socket.io GitHub issue #2800. Community reactions: 2 upvotes.

Verification Summary

Worked: 3
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

socket.iowebsocketrealtime