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

266
Views
socket io client not connecting to ip address but is connecting to localhost from p5 electron enviroment

i am writing a webapp that is built with electron(1.4.13) and p5js.

this webapp has a multi edit system that lets multiple users to edit the same document (like google docs). however i am having a isue where the socket server refuses conections to the p5js electron enviroment

error: polling-xhr.js:157 GET http://:5000/socket.io/?EIO=4&transport=polling&t=NyB7FTE net::ERR_CONNECTION_REFUSED

server.js:

const express = require('express');

class server {
   constructor(port) {
      this.port = port;
      this.app = express();
      this.http = require('http').Server(this.app);
      this.io = require('socket.io')(this.http);

      this.http.listen(port, () => console.log(`Hosted on port ${port}`));

      this.io.on('connection', function(socket) {
         console.log('A user connected');
     
         socket.on('disconnect', function () {
            console.log('A user disconnected');
         });
      });
   }
}

let _server = new server(5000);

client.js:

class client {
  constructor(host,port,onmessage) {
    this.socket = io("http://"+host+":"+port);//"ws://"+
    
    this.socket.on("message", data => {
      onmessage(data);
    });
  }

  disconect() {
    this.socket
  }

  write(ipda) {
    this.socket.send(ipda)
  }
}

let _client = new client('MY IP ADDRESS FOR TEST',5000,() => {console.log(data)});

index.html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Thinkin Box</title>
    <script language="javascript" type="text/javascript" src="libraries/p5.js"></script>
    <!--<script language="javascript" src="libraries/p5.dom.js"></script>-->
    <!--<script language="javascript" src="libraries/p5.sound.js"></script>-->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.js"></script>
    <script language="javascript" type="text/javascript" src="sketch.js"></script>
    <style> body {padding: 0; margin: 0; background: #000000; overflow-x:hidden; overflow-y: hidden} </style>
  </head>
  <body>

  </body>

  <script>
    // You can also require other files to run in this process
    require('../renderer.js')
  </script>
</html>
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!