Next JS API can't emit events to socket.io

Hi! We have a socket.io node server deployed to Azure that communicates with our web NextJs web application.

The Next app is deployed on netlify, and the client (the frontend) is able to emit and listen to events perfectly, both locally and after deployment.

Our Next API also needs to be able to emit events to the Azure socket io server, but for some reason, the API functions are not able to emit to Azure. There is no error produced whatsover, and the socketio server sees no inbound event or connection. The communication from our API to our Azure socket server works locally, just not once it’s deployed to netlify.

Not sure if there is any sort of guardrail in place from creating websocket connections in cloud functions?

This is more or less how we’re going about emitting from our API:

import { io } from 'socket.io-client';

const emit = () => {
  const socket = io(SOCKET_URL);
  socket.emit(`some-event`, someData);
  setTimeout(() => socket.disconnect(), 250);
}

Hi @joe.roddy :wave:t6: ,

Welcome back to the forums. Thank you for sharing this. Can you share your repo?