From 8f8155b2e6ed1b741422a0c692041a70c9582757 Mon Sep 17 00:00:00 2001 From: hamza zia Date: Sat, 6 Oct 2012 23:26:19 -0700 Subject: [PATCH] timeout heruistics improved --- js/connection.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/connection.js b/js/connection.js index d8a4305..2bde23b 100644 --- a/js/connection.js +++ b/js/connection.js @@ -1,7 +1,7 @@ var JsonRPC = function(conf) { if (!this instanceof JsonRPC) return new JsonRPC(); - this.avgTimeout = 1000; + this.avgTimeout = 2000; this.serverConf = conf; }; JsonRPC.prototype = { @@ -10,9 +10,10 @@ JsonRPC.prototype = { }, ariaRequest: function(url, multicall, funcName, params, success, error) { var startTime = new Date(); + var conn = this; $.ajax({ url: url, - timeout: 1000, + timeout: this.avgTimeout, data: { jsonrpc: 2.0, id: 'webui', @@ -20,7 +21,7 @@ JsonRPC.prototype = { params: params.length ? this.encode(params) : undefined }, success: function(data) { - this.avgTimeout = 3 * (new Date() - startTime); + conn.avgTimeout = 3 * (new Date() - startTime); return success(data) }, error: error,