Skip to content

Receiving "Callbacks are not support when broadcasting" when using multiple webapps via socket.emit #445

Closed
@Lucaszw

Description

@Lucaszw

We are using socket io callbacks when sending messages to particular connections. (We use heroku for hosting)

Server emit code looks like

const sockets  = await this.deviceSockets.in(channelName).fetchSockets()
for (const socket of sockets) {
socket.emit(eventName, ...args, function(err, result) {
...
});
}

Client code looks like

socket.on('ping', async (callback) => {
callback({ status: 'ok' })
})

This works fine when we only have one web server running; however when we have multiple webservers running (heroku dynos), we receive the following error when our clients try responding to the callbacks:

Callbacks are not support when broadcasting

However we aren't broadcasting (rather emitting to one particular client)

We are configuring socket-io redis in the following way:

const {createAdapter} = require('@socket.io/redis-adapter')
...
const pubClient = redis.createClient({...})
const subClient = this.pubClient.duplicate()
io.adapter(createAdapter(pubClient,subClient)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions