UPDATE:
It turns out the port 3000 on the remote server wasn't open. Thanks everyone for reading.
=========
Hello everyone.
I have a socket.io client that I connect to the socket.io server I'm running in my localhost using
const io = require('socket.io-client');
const chatSocket = io.connect('http://127.0.0.1:7000/');
Everything works well and I can send messages through the socket that are logged in the server.
This is the code I use on the server side:
let app = require("express")();
let http = require("http").Server(app);
let io = require("socket.io")(http);
io.on("connection", function() {
console.log("connected");
});
http.listen(port, function () {
console.log("listening in port 3000");
});
The problem is that "connected"
never logs when I run the same code on a remote server. Just the "listening in port 3000"
part. I'm substituting the server's IP address and port in io.connect()
. I even tried with the DNS name but it's still not connecting. I've checked the dependencies and they're the same as my local environment.
What could I be missing?