Am Donnerstag, den 05.04.2012, 23:19 -0700 schrieb AntZ:
> I use Node.js as HTTPS client, not a server. I need to issue some 10
> HTTPS requests a second to a remote server. It works, but every HTTPS
> request is in separate HTTPS connection.
> 
> The problem is in agent logic:
>     } else {
>       // If there are no pending requests just destroy the
>       // socket and it will get removed from the pool. This
>       // gets us out of timeout issues and allows us to
>       // default to Connection:keep-alive.
>       socket.destroy();
>     }
> 
> There are two choices:
> 1) There are more HTTPS requests to the location, keep connection live
> 2) No more HTTPS requests to the location, just close the connection
> 
> I desperatly need third variant - I want to keep connection alive as
> there will be next request in no longer than 100ms.
> 
> For now the only solution I see is to replace a standard Agent with my
> own one. Are there more simple solutions? Is there an easy way to make
> keepalive client connections disconnecting on timeout?
> 
> HTTPS connection handshake is expensive

Have a look at https://github.com/mikeal/request/blob/master/forever.js
- "request" can do forever requests (although I didn't know that isaacs
has added HTTPS support :) ).

Try something like this:

    var request = require('request').forever();
    // use request according to the documentation now

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to