tcp-base
Advanced tools
Comparing version 1.1.0 to 1.1.1
1.1.1 / 2017-08-11 | ||
================== | ||
* fix: add max idle time logic (#8) | ||
1.1.0 / 2016-11-30 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -409,5 +409,10 @@ 'use strict'; | ||
if (this.options.needHeartbeat) { | ||
const interval = this.options.heartbeatInterval; | ||
let maxIdleTime = this.options.maxIdleTime; | ||
if (!maxIdleTime || maxIdleTime < interval * 2) { | ||
maxIdleTime = interval * 2; | ||
} | ||
this._heartbeatTimer = setInterval(() => { | ||
const duration = this._lastHeartbeatTime - this._lastReceiveDataTime; | ||
if (this._lastReceiveDataTime && duration > this.options.heartbeatInterval) { | ||
if (this._lastReceiveDataTime && duration > maxIdleTime) { | ||
const err = new Error(`server ${this[addressKey]} no response in ${duration}ms, maybe the socket is end on the other side.`); | ||
@@ -424,3 +429,3 @@ err.name = 'ServerNoResponseError'; | ||
this.sendHeartBeat(); | ||
}, this.options.heartbeatInterval); | ||
}, interval); | ||
} | ||
@@ -427,0 +432,0 @@ } |
{ | ||
"name": "tcp-base", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A base class for tcp client with basic functions", | ||
@@ -10,7 +10,9 @@ "main": "lib/base.js", | ||
"scripts": { | ||
"lint": "eslint --ext .js lib test example", | ||
"autod": "autod", | ||
"lint": "eslint --ext .js .", | ||
"test": "npm run lint && npm run test-local", | ||
"test-local": "egg-bin test", | ||
"cov": "egg-bin cov", | ||
"ci": "npm run lint -- --fix && npm run cov" | ||
"cov": "TEST_TIMEOUT=20000 egg-bin cov", | ||
"ci": "npm run lint && npm run cov", | ||
"contributors": "contributors" | ||
}, | ||
@@ -37,15 +39,18 @@ "repository": { | ||
"devDependencies": { | ||
"egg-bin": "1", | ||
"egg-ci": "1", | ||
"eslint": "3", | ||
"eslint-config-egg": "3", | ||
"mm": "2", | ||
"npminstall": "2", | ||
"pedding": "1", | ||
"should": "11" | ||
"autod": "^2.9.0", | ||
"await-event": "^2.1.0", | ||
"contributors": "^0.5.1", | ||
"egg-bin": "^1.11.1", | ||
"egg-ci": "^1.8.0", | ||
"eslint": "^4.4.1", | ||
"eslint-config-egg": "^5.0.0", | ||
"mm": "^2.1.0", | ||
"mz-modules": "^1.0.0", | ||
"pedding": "^1.1.0", | ||
"webstorm-disable-index": "^1.2.0" | ||
}, | ||
"dependencies": { | ||
"is-type-of": "^1.0.0", | ||
"is-type-of": "^1.1.0", | ||
"sdk-base": "^2.0.1" | ||
} | ||
} |
17007
391
11
Updatedis-type-of@^1.1.0