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 8133185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:31:54+00:00 2026-06-06T09:31:54+00:00

I have a basic Socket.io server setup like this: var server = express.createServer().listen(port); this.io

  • 0

I have a basic Socket.io server setup like this:

var server = express.createServer().listen(port);
    this.io = socketIO.listen(server);

this.io.sockets.on('connection', function(socket){
        initSocket(socket);
    });

I also have socket.io configured to use XHR polling like so:

io.set("transports", ["xhr-polling"]);
io.set("close timeout", 3);
io.set("heartbeat interval", 2); 

The issue is every time the client sends a heartbeat (every 2 sec), the ‘connection’ event is being fired. Is there a different event I can use that will fire once each time a socket initially connects?

I would use the “authorization” event, but that only passes in a handshake object not the actual socket.

  • 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-06T09:31:55+00:00Added an answer on June 6, 2026 at 9:31 am

    Found the problem. I had my xhr “polling duration” set to heroku’s suggested 10s like so:

    io.set("polling duration", 10);
    

    Which means that the client only makes a new xhr request every 10 seconds (as soon as the previous request returns). At the same time I had the “close timeout” set to 3 seconds:

    io.set("close timeout", 3);
    

    Which means if the server does not hear from the client within 3 seconds since its last request it closes the connection, hence the continuous ‘disconnect/connection’ events being fired.

    The solution was to set the close timeout higher than the polling duration. It would seem that the “heartbeat interval” is not relevant for xhr connections.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic socket server that looks like this: IPEndPoint localEndPoint = new
So I have this very basic socket.io setup that you have probably seen a
I have created a basic flash socket server in PHP, it all works fine
I'm trying to implement basic communication through sockets, what I have now is: server
I have a WebSocket connection set up for a basic web chat server. Now,
i have set up a basic client and a basic server using java sockets.
I have basic Spring MVC 3 setup for i18n where I can show labels
I have a basic nServicebus 3.2.0 setup with a web application endpoint and a
I am implementing a really basic server-client model in Java, by using UDP sockets
I have a home grown web server in my app. This web server spawns

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.