Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
Socket io client cannot communicate to socket io server

Need your help/guidance/suggestion for our scenario.

Issue: I am having some trouble connecting socket io client to socket io server. The error I got after running this code is connection time out.

My server code is :

const port = process.env.PORT || 4004;
const http = require('http');
const socket = require('socket.io');
const app = express();
const httpServer = http.createServer(app);
const io = new socket.Server(httpServer);

io.on('connection', (socket) => {
    console.log("Socket connected");
});

httpServer.listen(port, () => {
    console.log("Listening on port ",port);
});

My client code is:

<script src = "socket.io.min.js"> </script>
<script>
    var socket = io.connect(`wss://${document.location.hostname}:${port}`);
    console.log(socket);
    socket.on('done', (data) => {
        console.log(data);
    });
 </script>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!