I run a chat portal built in NodeJS and React that is hosted on a Azure App Service. Recently with a lot more people using it we have been instructed by Microsoft to scale out the app essentially giving it more instances.
While this does fix the performance issues, the Socket.IO component of the portal then stops working as expected. It seems to only receive pings from Socket.IO once and a while which leads to the data not refreshing when it needs to. I have Websockets and ARR Affinity enabled on the app service, disabling ARR Affinity breaks the Socket.io functionality entirely. I am new to running NodeJS on multiple instances with Socket.IO so I would appreciate any feedback from the community on how to resolve this issue.
The Socket.IO is configured as followed:
Server index.js
const server = require('http').createServer(app);
const io = require('socket.io')(server);
app.io = io;
Client Side
import { io } from "socket.io-client";
const socket = io(null, {
reconnectionDelayMax: 3000,
reconnection: true,
reconnectionAttempts: Number.MAX_VALUE,
timeout: 7000
});
export default socket;