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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:36:46+00:00 2026-05-22T16:36:46+00:00

There is a post: How do I set a timeout for client http connections

  • 0

There is a post: How do I set a timeout for client http connections in node.js

but none of the answer will work.

So, I have the code like that:

    var remote_client = http.createClient(myPost, myHost);
    var path = '/getData?';
    var param = {       };

    var request = remote_client.request("POST", path,);

    // error case
    remote_client.addListener('error', function(connectionException){
        console.log("Nucleus Error: " + connectionException);
        next(connectionException);
    });

    request.addListener('response', function (response) {
        response.setEncoding('utf-8'); 
        var body = '';

        response.addListener('data', function (chunk) {

        // get the result!              
        });
    });

    request.end();

The biggest problem is that the url that I’m connection to may timeout. Therefore, I would like to set a timeout, like 15 secs. If so, trigger a listener.

However, I haven’t seen any timeout features in the documentation for http.createClient. Please advise. Thanks. 🙂

  • 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-05-22T16:36:47+00:00Added an answer on May 22, 2026 at 4:36 pm
    var foo = setTimeout(function() {
        request.emit("timeout-foo");
    }, 15000);
    
    // listen to timeout
    request.on("timeout-foo", function() { });
    
    request.addListener('response', function (response) {
        // bla
        // clear counter
        clearTimeout(foo);
    });
    

    Just run the counter yourself.

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

Sidebar

Related Questions

I know there is this post , but I still want to know more
I'm trying to measure the popularity of a post but there's no current system
Before I start, I know there is this post and it doesn't answer my
By @user.posts , I can see there is a post with :unfinished status. But
When programmatically issuing HTTP POST requests, what timeout values would be sensible? In my
Is there a way to Interupt a sleeping thread? If I have code similar
Can anyone post a sample code wherein theres a running timer(javascript settimeout) and doing
There was a post this morning asking about how many people disable JavaScript. Then
There's another post on SO relating to .NET -- not us. Pure PHP. Trying
There's a post-.NET 3.5 SP1 update which comes in x86 and x64 flavours: The

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.