{"action":"created","issue":{"url":"https://api.github.com/repos/grpc/grpc-go/issues/297","labels_url":"https://api.github.com/repos/grpc/grpc-go/issues/297/labels{/name}","comments_url":"https://api.github.com/repos/grpc/grpc-go/issues/297/comments","events_url":"https://api.github.com/repos/grpc/grpc-go/issues/297/events","html_url":"https://github.com/grpc/grpc-go/issues/297","id":101615123,"number":297,"title":"Is there a hook for server when the connection lost from client","user":{"login":"zj8487","id":5138447,"avatar_url":"https://avatars.githubusercontent.com/u/5138447?v=3","gravatar_id":"","url":"https://api.github.com/users/zj8487","html_url":"https://github.com/zj8487","followers_url":"https://api.github.com/users/zj8487/followers","following_url":"https://api.github.com/users/zj8487/following{/other_user}","gists_url":"https://api.github.com/users/zj8487/gists{/gist_id}","starred_url":"https://api.github.com/users/zj8487/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zj8487/subscriptions","organizations_url":"https://api.github.com/users/zj8487/orgs","repos_url":"https://api.github.com/users/zj8487/repos","events_url":"https://api.github.com/users/zj8487/events{/privacy}","received_events_url":"https://api.github.com/users/zj8487/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-18T09:40:57Z","updated_at":"2015-08-19T01:53:21Z","closed_at":null,"body":"the scene is as follow:\r\n```\r\nwhen client close or lose the connection and server want to do some resource clean\r\n```"},"comment":{"url":"https://api.github.com/repos/grpc/grpc-go/issues/comments/132414662","html_url":"https://github.com/grpc/grpc-go/issues/297#issuecomment-132414662","issue_url":"https://api.github.com/repos/grpc/grpc-go/issues/297","id":132414662,"user":{"login":"zj8487","id":5138447,"avatar_url":"https://avatars.githubusercontent.com/u/5138447?v=3","gravatar_id":"","url":"https://api.github.com/users/zj8487","html_url":"https://github.com/zj8487","followers_url":"https://api.github.com/users/zj8487/followers","following_url":"https://api.github.com/users/zj8487/following{/other_user}","gists_url":"https://api.github.com/users/zj8487/gists{/gist_id}","starred_url":"https://api.github.com/users/zj8487/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zj8487/subscriptions","organizations_url":"https://api.github.com/users/zj8487/orgs","repos_url":"https://api.github.com/users/zj8487/repos","events_url":"https://api.github.com/users/zj8487/events{/privacy}","received_events_url":"https://api.github.com/users/zj8487/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T01:53:21Z","updated_at":"2015-08-19T01:53:21Z","body":"# Shortage of abilitys for grpc\r\n* Checking the connection on client and server end\r\n* Marking the connection on client and server end\r\n\r\n## Checking the connection on client and server end\r\n**Why need the ability?**\r\n\r\nBoth client and server should know the status of the connection to the other side, so that the each end can do some work tor it. for example, reconnect, destroy the resource.\r\nmaybe you will say we can monitor the service status by zookeeper, etcd. yes, you are right. but it will not  work on mobile client.\r\n\r\n**What is the status of the connection?**\r\n\r\n* heartbeat timeout\r\n  grpc should supply the ability to config the heartbeat. the options is as follow:\r\n  * enable the heartbeat detect ---if no, no heartbeat package will send to detect the connection.\r\n  * the interval for the heartbeat package----send the heartbeat package every interval\r\n  * heartbeat timeout time----if no package received in the time, ```heartbeat timeout hook``` will be triggerd\r\n   * handshake between client and server. the client should detect the connection like server. but should use the same config as above used in server side. so handshake is needed to sync the config.\r\n\r\n   ***if the handshake is possible to sync the custom config is better***\r\n\r\n* connection lost for reason, ETIMEDOUT, EHOSTDOWN, EHOSTUNREACH, etc.\r\n  if the event of connection tiggerd, the hook will trggered\r\n\r\n## Marking the connection on client and server end\r\n**Why need the ability?**\r\nIn general, we can not give every connection a hook. so we should know the owner of the connection in the hook.\r\nfor exapmle, if a client logon by a ```login rpc function```, and then we record the userId or user object on the connection. and then, we will know who is lost in the hook function. \r\n\r\n@iamqizhao "}}