Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

socket.setTimeout is ignored after HTTP upgrade #2114

Closed
hanzi opened this issue Nov 15, 2011 · 3 comments
Closed

socket.setTimeout is ignored after HTTP upgrade #2114

hanzi opened this issue Nov 15, 2011 · 3 comments
Labels

Comments

@hanzi
Copy link

hanzi commented Nov 15, 2011

I did a basic WebSocket implementation on my own, which involves upgrading a HTTP connection. Node seems to set up a 2 minute idle timeout for these connections, which I guess is the default behavior for HTTP connections.

My connections can be idle for quite some time, so I wanted to disable this timeout. I tried

`````` socket.setTimeout(0);```
but that's totally getting ignored. The 'socket' object is fine -- immediately after this line I appended a listener for the 'timeout' event to it (for debugging purposes) and that worked.

Even more, not only does the 'timeout' event fire, it also closes the connection. I can prevent this by doing
socket.removeAllListeners('timeout');
but that's just a workaround.

Is this a bug or am I doing something wrong? Is there another way to disable that timeout?

(The 'socket' object is the one I received from the 'upgrade' event of the HTTP server.)

@bnoordhuis
Copy link
Member

Do you have a test case I can try? It seems to work for me and I don't see anything in lib/net.js or lib/http.js that could cause it to fail. By the way, with what version of Node are you seeing this behaviour?

@jameshartig
Copy link

Running:
https://gist.github.com/1422141

Generated:
/usr/local/bin/node testTimeout.js
setTimeout(0) failed. Timed out!
setTimeout(0) worked correctly 2nd time.

@jameshartig
Copy link

Ignore 8fb848c. I originally though that would fix it but it caused issues.

jameshartig pushed a commit to jameshartig/node that referenced this issue Dec 19, 2011
jameshartig pushed a commit to jameshartig/node that referenced this issue Dec 19, 2011
alexkwolfe pushed a commit to alexkwolfe/node that referenced this issue Dec 23, 2011
Stops .active() from reactivating the timer.

Fixes nodejs#2114.
isaacs added a commit to isaacs/node-v0.x-archive that referenced this issue Jan 6, 2012
* Upgrade V8 to 3.6.6.15

* Upgrade npm to 1.1.0-beta-10 (isaacs)

* many doc updates (Ben Noordhuis, Jeremy Martin, koichik, Dave Irvine,
  Seong-Rak Choi, Shannen, Adam Malcontenti-Wilson, koichik)

* nodejs#2438 segfault in node v0.6.6

* dgram, timers: fix memory leaks (Ben Noordhuis, Yoshihiro Kukuchi)

* repl: fix repl.start not passing the `ignoreUndefined` arg (Damon Oehlman)

* nodejs#1980: Socket.pause null reference when called on a closed Stream (koichik)

* nodejs#2263: XMLHttpRequest piped in a writable file stream hang (koichik)

* nodejs#2069: http resource leak (koichik)

* buffer.readInt global pollution fix (Phil Sung)

* timers: fix performance regression (Ben Noordhuis)

* nodejs#2308, nodejs#2246: node swallows openssl error on request (koichik)

* nodejs#2114: timers: remove _idleTimeout from item in .unenroll() (James Hartig)

* nodejs#2379: debugger: Request backtrace w/o refs (Fedor Indutny)

* simple DTrace ustack helper (Dave Pacheco)

* crypto: rewrite HexDecode without snprintf (Roman Shtylman)

* crypto: add SecureContext.clearOptions() method (Ben Noordhuis)

* crypto: don't ignore DH init errors (Ben Noordhuis)
isaacs added a commit that referenced this issue Jan 7, 2012
* V8 hash collision fix (Breaks MIPS) (Bert Belder, Erik Corry)

* Upgrade V8 to 3.6.6.15

* Upgrade npm to 1.1.0-beta-10 (isaacs)

* many doc updates (Ben Noordhuis, Jeremy Martin, koichik, Dave Irvine,
  Seong-Rak Choi, Shannen, Adam Malcontenti-Wilson, koichik)

* Fix segfault in node_http_parser.cc

* dgram, timers: fix memory leaks (Ben Noordhuis, Yoshihiro Kukuchi)

* repl: fix repl.start not passing the `ignoreUndefined` arg (Damon Oehlman)

* #1980: Socket.pause null reference when called on a closed Stream (koichik)

* #2263: XMLHttpRequest piped in a writable file stream hang (koichik)

* #2069: http resource leak (koichik)

* buffer.readInt global pollution fix (Phil Sung)

* timers: fix performance regression (Ben Noordhuis)

* #2308, #2246: node swallows openssl error on request (koichik)

* #2114: timers: remove _idleTimeout from item in .unenroll() (James Hartig)

* #2379: debugger: Request backtrace w/o refs (Fedor Indutny)

* simple DTrace ustack helper (Dave Pacheco)

* crypto: rewrite HexDecode without snprintf (Roman Shtylman)

* crypto: don't ignore DH init errors (Ben Noordhuis)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants