Skip to content

Commit

Permalink
Defaulting maxSockets to null
Browse files Browse the repository at this point in the history
  • Loading branch information
geek committed May 13, 2013
1 parent 20ccca2 commit e0f7523
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ When creating a server instance, the following options configure the server's be
- `tls` - used to create an HTTPS server. The `tls` object is passed unchanged as options to the node.js HTTPS server as described in the
[node.js HTTPS documentation](http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener).
<p></p>
- `maxSockets` - used to set the number of sockets available per outgoing host connection. Default is 5. This impacts all servers sharing the process.
- `maxSockets` - used to set the number of sockets available per outgoing host connection. Default is null. This impacts all servers sharing the process.
<p></p>
- <a name="server.config.views"></a>`views` - enables support for view rendering (using templates to generate responses). Disabled by default.
To enable, set to an object with the following options:
Expand Down
5 changes: 3 additions & 2 deletions lib/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ exports.server = {
// cert: ''
// },

maxSockets: null, // Sets http/https globalAgent maxSockets value

// Router

router: {
Expand Down Expand Up @@ -80,8 +82,7 @@ exports.server = {

cors: false, // CORS headers on responses and OPTIONS requests (defaults: exports.cors): false -> null, true -> defaults, {} -> override defaults
views: null, // Views engine
auth: {}, // Authentication
maxSockets: 5 // Sets http/https globalAgent maxSockets value
auth: {} // Authentication
};


Expand Down
6 changes: 4 additions & 2 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ module.exports = internals.Server = function (/* host, port, options */) {
this.listener = Http.createServer(this._dispatch());
}

Https.globalAgent.maxSockets = this.settings.maxSockets;
Http.globalAgent.maxSockets = this.settings.maxSockets;
if (this.settings.maxSockets !== null) {
Https.globalAgent.maxSockets = this.settings.maxSockets;
Http.globalAgent.maxSockets = this.settings.maxSockets;
}

// Authentication

Expand Down

2 comments on commit e0f7523

@garthk
Copy link

@garthk garthk commented on e0f7523 Jan 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I reading the code right? If a server has maxSockets, you over-write the global agent's maxSockets, affecting every server.

@garthk
Copy link

@garthk garthk commented on e0f7523 Jan 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raised as #1346.

Please sign in to comment.