• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# timed-out [![Build Status](https://travis-ci.org/floatdrop/timed-out.svg?branch=master)](https://travis-ci.org/floatdrop/timed-out)
2
3> Timeout HTTP/HTTPS requests
4
5Emit Error object with `code` property equal `ETIMEDOUT` or `ESOCKETTIMEDOUT` when ClientRequest is hanged.
6
7## Usage
8
9```js
10var get = require('http').get;
11var timeout = require('timed-out');
12
13var req = get('http://www.google.ru');
14timeout(req, 2000); // Set 2 seconds limit
15```
16
17### API
18
19#### timedout(request, time)
20
21##### request
22
23*Required*
24Type: [`ClientRequest`](http://nodejs.org/api/http.html#http_class_http_clientrequest)
25
26The request to watch on.
27
28##### time
29
30*Required*
31Type: `number` or `object`
32
33Time in milliseconds to wait for `connect` event on socket and also time to wait on inactive socket.
34
35Or you can pass Object with following fields:
36
37- `connect` - time to wait for connection
38- `socket`  - time to wait for activity on socket
39
40## License
41
42MIT © [Vsevolod Strukchinsky](floatdrop@gmail.com)
43