Re: [nodejs] No setTimeout() on HTTPS server...

287 views
Skip to first unread message

Ben Noordhuis

unread,
Apr 24, 2013, 3:04:03 PM4/24/13
to nod...@googlegroups.com
On Wed, Apr 24, 2013 at 8:46 PM, Craig Hockenberry
<craig.ho...@gmail.com> wrote:
> I'd like to change the socket timeout for an HTTPS server instance, but find
> that the following doesn't work:
>
> var options = {
> key: fs.readFileSync('ssl/my.key'),
> cert: fs.readFileSync('ssl/my.crt'),
> ca: fs.readFileSync('ssl/myca.crt'),
> handshakeTimeout: 20000,
> };
> var server = https.createServer(options, requestListener);
> server.setTimeout(30000);
> server.listen(8080);
>
> In our development environment, where we use an HTTP server, the timeout
> works great.
>
> I'm wondering if there is some technical reason why SSL connections can't
> time out, or if this is just an oversight.
>
> Thanks in advance for any help/insight.
>
> -ch

It's an oversight. I've filed an issue[1].

[1] https://github.com/joyent/node/issues/5361

Craig Hockenberry

unread,
Apr 24, 2013, 6:25:37 PM4/24/13
to nod...@googlegroups.com
Thanks Ben!

I'd assume that something like this in the requestListener is the best way to set the timeouts in the interim:

function requestTimeout() {
request.abort();
}

function responseTimeout() {
errorResponse(500, 'TIMEOUT');
}

request.setTimeout(30000, requestTimeout);
response.setTimeout(30000, responseTimeout);

-ch

Ben Noordhuis

unread,
Apr 25, 2013, 3:59:21 AM4/25/13
to nod...@googlegroups.com
On Thu, Apr 25, 2013 at 12:25 AM, Craig Hockenberry
<craig.ho...@gmail.com> wrote:
> Thanks Ben!
>
> I'd assume that something like this in the requestListener is the best way
> to set the timeouts in the interim:
>
> function requestTimeout() {
> request.abort();
> }
>
> function responseTimeout() {
> errorResponse(500, 'TIMEOUT');
> }
>
> request.setTimeout(30000, requestTimeout);
> response.setTimeout(30000, responseTimeout);
>
> -ch

Yep, that should work.
Reply all
Reply to author
Forward
0 new messages