{"action":"created","issue":{"url":"https://api.github.com/repos/node-modules/cluster-client/issues/34","repository_url":"https://api.github.com/repos/node-modules/cluster-client","labels_url":"https://api.github.com/repos/node-modules/cluster-client/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/node-modules/cluster-client/issues/34/comments","events_url":"https://api.github.com/repos/node-modules/cluster-client/issues/34/events","html_url":"https://github.com/node-modules/cluster-client/pull/34","id":265223104,"number":34,"title":"fix: follower _registerChannel retry forever, when socket closed passively","user":{"login":"xiamengyu","id":7949004,"avatar_url":"https://avatars1.githubusercontent.com/u/7949004?v=4","gravatar_id":"","url":"https://api.github.com/users/xiamengyu","html_url":"https://github.com/xiamengyu","followers_url":"https://api.github.com/users/xiamengyu/followers","following_url":"https://api.github.com/users/xiamengyu/following{/other_user}","gists_url":"https://api.github.com/users/xiamengyu/gists{/gist_id}","starred_url":"https://api.github.com/users/xiamengyu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiamengyu/subscriptions","organizations_url":"https://api.github.com/users/xiamengyu/orgs","repos_url":"https://api.github.com/users/xiamengyu/repos","events_url":"https://api.github.com/users/xiamengyu/events{/privacy}","received_events_url":"https://api.github.com/users/xiamengyu/received_events","type":"User","site_admin":false},"labels":[{"id":498958829,"url":"https://api.github.com/repos/node-modules/cluster-client/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"open","locked":false,"assignee":{"login":"fengmk2","id":156269,"avatar_url":"https://avatars0.githubusercontent.com/u/156269?v=4","gravatar_id":"","url":"https://api.github.com/users/fengmk2","html_url":"https://github.com/fengmk2","followers_url":"https://api.github.com/users/fengmk2/followers","following_url":"https://api.github.com/users/fengmk2/following{/other_user}","gists_url":"https://api.github.com/users/fengmk2/gists{/gist_id}","starred_url":"https://api.github.com/users/fengmk2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fengmk2/subscriptions","organizations_url":"https://api.github.com/users/fengmk2/orgs","repos_url":"https://api.github.com/users/fengmk2/repos","events_url":"https://api.github.com/users/fengmk2/events{/privacy}","received_events_url":"https://api.github.com/users/fengmk2/received_events","type":"User","site_admin":false},"assignees":[{"login":"fengmk2","id":156269,"avatar_url":"https://avatars0.githubusercontent.com/u/156269?v=4","gravatar_id":"","url":"https://api.github.com/users/fengmk2","html_url":"https://github.com/fengmk2","followers_url":"https://api.github.com/users/fengmk2/followers","following_url":"https://api.github.com/users/fengmk2/following{/other_user}","gists_url":"https://api.github.com/users/fengmk2/gists{/gist_id}","starred_url":"https://api.github.com/users/fengmk2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fengmk2/subscriptions","organizations_url":"https://api.github.com/users/fengmk2/orgs","repos_url":"https://api.github.com/users/fengmk2/repos","events_url":"https://api.github.com/users/fengmk2/events{/privacy}","received_events_url":"https://api.github.com/users/fengmk2/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2017-10-13T09:21:36Z","updated_at":"2017-10-16T03:48:49Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/node-modules/cluster-client/pulls/34","html_url":"https://github.com/node-modules/cluster-client/pull/34","diff_url":"https://github.com/node-modules/cluster-client/pull/34.diff","patch_url":"https://github.com/node-modules/cluster-client/pull/34.patch"},"body":"修复，当`Follower`跟`Leader`的连接非主动断开（调用close）时，如果恰好执行到`Follower` 的`_registerChannel`方法时，会导致`_registerChannel`方法的中`this.send`报错后3秒重试，并一直进行下去。因为连接断开后client会调用`[init]`方法，该方法会new 一个新的`Follower`,原先旧的`Follower`如果在正在进行`_registerChannel` `setTimeout`重试,就会一直进行下去，因为`_registerChannel`中的`this.send`一直会失败。对应的错误栈信息：\r\n```\r\n2017-10-12 14:10:13,311 WARN 8618 [ClusterClient:ZookeeperAPIClient@192.168.1.123:2181,192.168.1.119:2181,192.168.1.120:2181,192.168.1.121:2181,192.168.1.122:2181] follower closed, and try to init it again\r\n^[[32m[2017-10-12 14:10:13.344] [INFO] mercurylock - ^[[39m[2,8618] - connected success!!\r\n2017-10-12 14:10:16,312 WARN 8618 nodejs.Error: register to channel: ZookeeperAPIClient@192.168.1.123:2181,192.168.1.119:2181,192.168.1.120:2181,192.168.1.121:2181,192.168.1.122:2181 failed, will retry after 3s, [TCPBase] The socket was closed. (address: 127.0.0.1:21789)\r\n    at Follower.send (/data/server/lock-sxlock/node_modules/tcp-base/lib/base.js:182:19)\r\n    at Follower.send (/data/server/lock-sxlock/node_modules/cluster-client/lib/follower.js:106:18)\r\n    at Follower._registerChannel (/data/server/lock-sxlock/node_modules/cluster-client/lib/follower.js:216:10)\r\n    at Timeout.setTimeout (/data/server/lock-sxlock/node_modules/cluster-client/lib/follower.js:225:31)\r\n    at Timeout._onTimeout (/data/server/lock-sxlock/node_modules/async-listener/glue.js:188:31)\r\n    at tryOnTimeout (timers.js:232:11)\r\n    at Timer.listOnTimeout (timers.js:202:5)\r\n```"},"comment":{"url":"https://api.github.com/repos/node-modules/cluster-client/issues/comments/336773520","html_url":"https://github.com/node-modules/cluster-client/pull/34#issuecomment-336773520","issue_url":"https://api.github.com/repos/node-modules/cluster-client/issues/34","id":336773520,"user":{"login":"fengmk2","id":156269,"avatar_url":"https://avatars0.githubusercontent.com/u/156269?v=4","gravatar_id":"","url":"https://api.github.com/users/fengmk2","html_url":"https://github.com/fengmk2","followers_url":"https://api.github.com/users/fengmk2/followers","following_url":"https://api.github.com/users/fengmk2/following{/other_user}","gists_url":"https://api.github.com/users/fengmk2/gists{/gist_id}","starred_url":"https://api.github.com/users/fengmk2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fengmk2/subscriptions","organizations_url":"https://api.github.com/users/fengmk2/orgs","repos_url":"https://api.github.com/users/fengmk2/repos","events_url":"https://api.github.com/users/fengmk2/events{/privacy}","received_events_url":"https://api.github.com/users/fengmk2/received_events","type":"User","site_admin":false},"created_at":"2017-10-16T03:48:49Z","updated_at":"2017-10-16T03:48:49Z","author_association":"OWNER","body":"@gxcsoccer 看看这个bug"}}
{"actor":{"display_login":"fengmk2"}}