Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8429169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:15:37+00:00 2026-06-10T05:15:37+00:00

I have seen some post on this forum regarding Socket.IO and node.js. But still

  • 0

I have seen some post on this forum regarding Socket.IO and node.js. But still isn’t working optimally.

port 80 and port 8080 are used by my webserver for different applications. So in App.js and my socket connection I added port 8081 instead of 8080.

I’m getting the websocket connection invalid message. After 10 seconds or so it has created the websocket and i’m able to use it perfectly well.

But 10 seconds is a too long. Any ideas how to fix this?

script.js:

 <script>
var socket = io.connect('http://domainname.nl:8081');


socket.on('connect', function(){

socket.emit('adduser', "<?php echo $user->first_name; ?>");
});

app.js

var app = require('express').createServer()
var io = require('socket.io').listen(8081);

app.listen(8081);

// routing
app.get('/', function (req, res) {
  res.sendfile(__dirname + '/index.html');
});

UPDATE:

When I have changed it. I still got the problem. The sockets works but takes 10 seconds to get connected

 info  - socket.io started
   debug - served static /socket.io.js
   debug - client authorized
   info  - handshake authorized 15619940591959058675
   debug - setting request GET /socket.io/1/websocket/15619940591959058675
   debug - set heartbeat interval for client 15619940591959058675
   warn  - websocket connection invalid
   info  - transport end
   debug - set close timeout for client 15619940591959058675
   debug - cleared close timeout for client 15619940591959058675
   debug - cleared heartbeat interval for client 15619940591959058675
   debug - client authorized for
   debug - setting request GET /socket.io/1/xhr-polling/15619940591959058675?t=1345479037596
   debug - setting poll timeout
   debug - clearing poll timeout
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:15:38+00:00Added an answer on June 10, 2026 at 5:15 am

    You’re effectively trying to start two different servers, one for your app and one for socket.io, both using the same port, 8081:

    var app = require('express').createServer()
    var io = require('socket.io').listen(8081);
    
    app.listen(8081);
    

    You can pass a port number to socket.io like this, but if you’re going to run it with a node http server you should pass that (i.e., app) to listen, like so:

    var app = require('express').createServer()
    var io = require('socket.io').listen(app);
    
    app.listen(8081);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I already seen some question from here (stackoverflow) and THIS post, but I still
I have seen some of the other answers on this topic but dont really
I have seen this post: Display GIF in a WP7 application with Silverlight But
Quite some time i`ve learnt MVC. I have seen various techniques to post data
I have seen some related questions but none focusing on the specific problem I
i have seen some hand rolled solutions but does jquery out of the box
I have seen some links that tells how to use web client but one
I have seen some links that tells how to use web client but one
I have seen the same topics here and some topics on other sites, but
Have seen some similar questions: What is the difference between a JavaBean and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.