Closed
Description
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)