GithubHelp home page GithubHelp logo

timeout not work about needle HOT 4 CLOSED

michael2043 avatar michael2043 commented on July 19, 2024
timeout not work

from needle.

Comments (4)

tomas avatar tomas commented on July 19, 2024

What URL are you aiming at? So I can replicate the same error. :)

from needle.

bitinn avatar bitinn commented on July 19, 2024

If I follow this correctly, after needle starts a connection and have received some data, it won't timeout until the file is fully received (besides the 2 minutes timeout on http)? I see no config in request for this neither, curl is the only thing I can think of that offers transfer timeout as an option.

request has a response event that you can listen to and set a manual timeout, I assume needle has something similar so that we can do the same thing?

But either way, Promise.race can wrap the needle request with another timeout that help to approximate a transfer timeout.

from needle.

tomas avatar tomas commented on July 19, 2024

Needle's timeout is set when the request is sent, and canceled only when we get a response with headers (no body yet). It's similar to curl's --connect-timeout option. You can always set a timeout for the full operation to complete:

var stream = needle.get('foobar.com/test'),
     timer = setTimeout(function() { stream.request.abort() }, 60 * 1000);

stream.on('end', function() { clearTimeout(timer) });

Does that solve the problem?

from needle.

tomas avatar tomas commented on July 19, 2024

Needle already handles open_timeout vs read_timeout. Try them out and let me know if it works (closing this issue, but feel free to reopen if it's not working as expected).

from needle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.