I\'m trying to build an endpoint that will receive a request, emit the request data to a WebSocket client, wait for an event, then send back the response using express + soc
Please note that:
socket.on('res', function (data) { res.status(200).json(data); });
Is being called each time a socket is sending a response, thus showing the above error. You should unbind the listener inside the callback function.