Skip to content

Commit fc05642

Browse files
committed
Add a host option to the connection parameters and disable the idle timeout
1 parent f76054b commit fc05642

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Diff for: postgres.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,20 @@ function parse_response(code, stream) {
167167
}
168168

169169

170-
exports.Connection = function (database, username, password, port) {
170+
exports.Connection = function (database, username, password, port, host) {
171171
var connection, events, query_queue, row_description, query_callback, results, readyState, closeState;
172172

173173
// Default to port 5432
174-
if (port === undefined) {
175-
port = 5432;
176-
}
174+
port = port || 5432;
175+
176+
// Default to host 127.0.0.1
177+
host = host || '127.0.0.1';
178+
179+
connection = tcp.createConnection(port, host);
180+
181+
// Disable the idle timeout on the connection
182+
connection.setTimeout(0);
177183

178-
connection = tcp.createConnection(port);
179184
events = new process.EventEmitter();
180185
query_queue = [];
181186
readyState = false;

0 commit comments

Comments
 (0)