Use 15-second timeout for service connections

This should reduce failures to send package stats.
This commit is contained in:
David Glasser
2014-08-19 12:38:36 -07:00
parent 52e3eafa5c
commit fceacf2885
5 changed files with 10 additions and 5 deletions

View File

@@ -58,7 +58,8 @@ var Connection = function (url, options) {
// fail (e.g. sending package usage stats). At some point we
// should have a real API for handling client-stream-level
// errors.
_dontPrintErrors: options._dontPrintErrors
_dontPrintErrors: options._dontPrintErrors,
connectTimeoutMs: options.connectTimeoutMs
});
}

View File

@@ -96,13 +96,13 @@ _.extend(LivedataTest.ClientStream.prototype, {
},
_initCommon: function () {
_initCommon: function (options) {
var self = this;
//// Constants
// how long to wait until we declare the connection attempt
// failed.
self.CONNECT_TIMEOUT = 10000;
self.CONNECT_TIMEOUT = options.connectTimeoutMs || 10000;
self.eventCallbacks = {}; // name -> [callback]

View File

@@ -22,7 +22,7 @@ LivedataTest.ClientStream = function (endpoint, options) {
self.headers = self.options.headers || {};
self._initCommon();
self._initCommon(options);
//// Kickoff!
self._launchConnection();

View File

@@ -6,7 +6,7 @@ LivedataTest.ClientStream = function (url, options) {
self.options = _.extend({
retry: true
}, options);
self._initCommon();
self._initCommon(options);
//// Constants

View File

@@ -30,6 +30,10 @@ var ServiceConnection = function (Package, endpointUrl, options) {
// ServiceConnection never should retry connections: just one TCP connection
// is enough, and any errors on it should be detected promptly.
options = _.extend({}, options, {
// We found that this was likely to time out with the DDP default of 10s,
// especially if the CPU is churning on bundling (eg, for the stats
// connection which we start in parallel with bundling).
connectTimeoutMs: 15000,
retry: false,
onConnected: function () {
if (!self.currentFuture)