SocketIO not working (anymore) on Ubuntu Server

Viewed 233

For a few days, my socketio client can't connect to my node / express app anymore (on Digital Ocean). It does work when running on my local machine and connecting via localhost (with a react-native app). I have also implemented REST / HTTP functionality, which also does work when running on the 'production' server. Everything is set up like in the Digital Ocean tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04

Server Code:

const app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);

var users = [];

app.set('io', io);
app.set('users', users);

server.listen(3002, () => {console.log('listening on 3002')});


io.on('connection', async (socket) => {
    console.log('User connected');
    ...
    ...
    ...
}
const testRoute = require('./routes/test');
app.use('/test', testRoute);

Because the HTTP part works I'd assume that any blocked ports aren't the problem, but I just can't find any solution to this problem. Also, this problem occurred just a few days ago, everything did work as intended already.7

EDIT 1: Found out the problem is nginx. Don't know what exactly yet, but when connecting socket io without nginx everything works as intended.

0 Answers
Related