{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls/comments/215800937","pull_request_review_id":153149946,"id":215800937,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNTgwMDkzNw==","diff_hunk":"@@ -219,7 +220,11 @@ async Task<T> ExecuteWithErrorHandlingAsync<T>(Func<Task<T>> asyncOperation, boo\n                             throw new IotHubClientTransientException(\"Transient error occurred, please retry.\", ex);\n                         }\n \n-                        await this.Reset(openCompletionBeforeOperationStarted, handlerBeforeOperationStarted).ConfigureAwait(false);\n+                        if (reset)","path":"iothub/device/src/Transport/ErrorDelegatingHandler.cs","position":31,"original_position":31,"commit_id":"7af4d85ef7b3c50ba2f350cdf2f230551baf641d","original_commit_id":"7af4d85ef7b3c50ba2f350cdf2f230551baf641d","user":{"login":"CIPop","id":8635911,"node_id":"MDQ6VXNlcjg2MzU5MTE=","avatar_url":"https://avatars2.githubusercontent.com/u/8635911?v=4","gravatar_id":"","url":"https://api.github.com/users/CIPop","html_url":"https://github.com/CIPop","followers_url":"https://api.github.com/users/CIPop/followers","following_url":"https://api.github.com/users/CIPop/following{/other_user}","gists_url":"https://api.github.com/users/CIPop/gists{/gist_id}","starred_url":"https://api.github.com/users/CIPop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CIPop/subscriptions","organizations_url":"https://api.github.com/users/CIPop/orgs","repos_url":"https://api.github.com/users/CIPop/repos","events_url":"https://api.github.com/users/CIPop/events{/privacy}","received_events_url":"https://api.github.com/users/CIPop/received_events","type":"User","site_admin":false},"body":"/cc @tameraw @abhipsaMisra \r\n\r\nWe need to investigate all other cases for this as it appears to be an old design-level bug: InternalClient (Device/Module) has a circular dependency through some of the callbacks. \r\nInstead of having the state machine spread out between Error, Retry and InternalClient callbacks we should push the logic into the correct handler.","created_at":"2018-09-06T22:46:43Z","updated_at":"2018-09-06T22:46:43Z","html_url":"https://github.com/Azure/azure-iot-sdk-csharp/pull/611#discussion_r215800937","pull_request_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls/611","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls/comments/215800937"},"html":{"href":"https://github.com/Azure/azure-iot-sdk-csharp/pull/611#discussion_r215800937"},"pull_request":{"href":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls/611"}}},"pull_request":{"url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls/611","id":213179919,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEzMTc5OTE5","html_url":"https://github.com/Azure/azure-iot-sdk-csharp/pull/611","diff_url":"https://github.com/Azure/azure-iot-sdk-csharp/pull/611.diff","patch_url":"https://github.com/Azure/azure-iot-sdk-csharp/pull/611.patch","issue_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/issues/611","number":611,"state":"open","locked":false,"title":"Amqp link recovery fix","user":{"login":"varunpuranik","id":8727929,"node_id":"MDQ6VXNlcjg3Mjc5Mjk=","avatar_url":"https://avatars1.githubusercontent.com/u/8727929?v=4","gravatar_id":"","url":"https://api.github.com/users/varunpuranik","html_url":"https://github.com/varunpuranik","followers_url":"https://api.github.com/users/varunpuranik/followers","following_url":"https://api.github.com/users/varunpuranik/following{/other_user}","gists_url":"https://api.github.com/users/varunpuranik/gists{/gist_id}","starred_url":"https://api.github.com/users/varunpuranik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/varunpuranik/subscriptions","organizations_url":"https://api.github.com/users/varunpuranik/orgs","repos_url":"https://api.github.com/users/varunpuranik/repos","events_url":"https://api.github.com/users/varunpuranik/events{/privacy}","received_events_url":"https://api.github.com/users/varunpuranik/received_events","type":"User","site_admin":false},"body":"## Checklist\r\n- [X] I have read the [contribution guidelines](https://github.com/Azure/azure-iot-sdk-csharp/blob/master/.github/CONTRIBUTING.md).\r\n- [X] This pull-request is submitted against the `master` branch.\r\n\r\n## Description of the changes\r\nIssue: Over AMQP, the link recovery callbacks don't retry multiple times. Because of this, if the server is not available when the first retry happens, the link goes silent. This affects receiving links - receiving messages, method invocations and twin updates. In particular, I was investigating this for the receiving messages link.\r\n\r\nUnderlying cause: The error delegating handler cleans up all connections if an exception is thrown. This causes the links to get closed entirely, and the retry gets cancelled. This works for MQTT, since it expects the connection to be closed, and re-opened in the next retry. On the other hand, for AMQP, each link is treated separately, and as such, the connection (and all its links) should not be closed if the recovery fails once. So added code to reset the connection only for MQTT.\r\nI spent significant time trying other options and somehow \"unifying\" the approach for both AMQP and MQTT, but because of the way the 2 protocols are written and expected to behave, this was not possible, without a significant refactor of the codebase.\r\nThe proposed fix works for both cases.\r\n\r\nTests: I will work with @CIPop to add E2E tests for these scenarios.\r\n\r\n## Reference/Link to the issue solved with this PR (if any)\r\nhttps://github.com/Azure/azure-iot-sdk-csharp/issues/571\r\n","created_at":"2018-09-05T06:15:53Z","updated_at":"2018-09-06T22:46:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ad660ba32ecd3587c331801e5b2b47b0d9e592c","assignee":null,"assignees":[],"requested_reviewers":[{"login":"abhipsaMisra","id":22563986,"node_id":"MDQ6VXNlcjIyNTYzOTg2","avatar_url":"https://avatars1.githubusercontent.com/u/22563986?v=4","gravatar_id":"","url":"https://api.github.com/users/abhipsaMisra","html_url":"https://github.com/abhipsaMisra","followers_url":"https://api.github.com/users/abhipsaMisra/followers","following_url":"https://api.github.com/users/abhipsaMisra/following{/other_user}","gists_url":"https://api.github.com/users/abhipsaMisra/gists{/gist_id}","starred_url":"https://api.github.com/users/abhipsaMisra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhipsaMisra/subscriptions","organizations_url":"https://api.github.com/users/abhipsaMisra/orgs","repos_url":"https://api.github.com/users/abhipsaMisra/repos","events_url":"https://api.github.com/users/abhipsaMisra/events{/privacy}","received_events_url":"https://api.github.com/users/abhipsaMisra/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls/611/commits","review_comments_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls/611/comments","review_comment_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/issues/611/comments","statuses_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/statuses/7af4d85ef7b3c50ba2f350cdf2f230551baf641d","head":{"label":"varunpuranik:AmqpLinkRecoveryFix1","ref":"AmqpLinkRecoveryFix1","sha":"7af4d85ef7b3c50ba2f350cdf2f230551baf641d","user":{"login":"varunpuranik","id":8727929,"node_id":"MDQ6VXNlcjg3Mjc5Mjk=","avatar_url":"https://avatars1.githubusercontent.com/u/8727929?v=4","gravatar_id":"","url":"https://api.github.com/users/varunpuranik","html_url":"https://github.com/varunpuranik","followers_url":"https://api.github.com/users/varunpuranik/followers","following_url":"https://api.github.com/users/varunpuranik/following{/other_user}","gists_url":"https://api.github.com/users/varunpuranik/gists{/gist_id}","starred_url":"https://api.github.com/users/varunpuranik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/varunpuranik/subscriptions","organizations_url":"https://api.github.com/users/varunpuranik/orgs","repos_url":"https://api.github.com/users/varunpuranik/repos","events_url":"https://api.github.com/users/varunpuranik/events{/privacy}","received_events_url":"https://api.github.com/users/varunpuranik/received_events","type":"User","site_admin":false},"repo":{"id":111614585,"node_id":"MDEwOlJlcG9zaXRvcnkxMTE2MTQ1ODU=","name":"azure-iot-sdk-csharp","full_name":"varunpuranik/azure-iot-sdk-csharp","owner":{"login":"varunpuranik","id":8727929,"node_id":"MDQ6VXNlcjg3Mjc5Mjk=","avatar_url":"https://avatars1.githubusercontent.com/u/8727929?v=4","gravatar_id":"","url":"https://api.github.com/users/varunpuranik","html_url":"https://github.com/varunpuranik","followers_url":"https://api.github.com/users/varunpuranik/followers","following_url":"https://api.github.com/users/varunpuranik/following{/other_user}","gists_url":"https://api.github.com/users/varunpuranik/gists{/gist_id}","starred_url":"https://api.github.com/users/varunpuranik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/varunpuranik/subscriptions","organizations_url":"https://api.github.com/users/varunpuranik/orgs","repos_url":"https://api.github.com/users/varunpuranik/repos","events_url":"https://api.github.com/users/varunpuranik/events{/privacy}","received_events_url":"https://api.github.com/users/varunpuranik/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/varunpuranik/azure-iot-sdk-csharp","description":"A C# SDK for connecting devices to Microsoft Azure IoT services","fork":true,"url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp","forks_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/forks","keys_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/teams","hooks_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/hooks","issue_events_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/issues/events{/number}","events_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/events","assignees_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/assignees{/user}","branches_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/branches{/branch}","tags_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/tags","blobs_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/git/refs{/sha}","trees_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/statuses/{sha}","languages_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/languages","stargazers_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/stargazers","contributors_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/contributors","subscribers_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/subscribers","subscription_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/subscription","commits_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/commits{/sha}","git_commits_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/git/commits{/sha}","comments_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/comments{/number}","issue_comment_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/issues/comments{/number}","contents_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/contents/{+path}","compare_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/merges","archive_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/downloads","issues_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/issues{/number}","pulls_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/pulls{/number}","milestones_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/milestones{/number}","notifications_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/labels{/name}","releases_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/releases{/id}","deployments_url":"https://api.github.com/repos/varunpuranik/azure-iot-sdk-csharp/deployments","created_at":"2017-11-21T23:51:08Z","updated_at":"2018-09-05T05:46:52Z","pushed_at":"2018-09-05T05:58:59Z","git_url":"git://github.com/varunpuranik/azure-iot-sdk-csharp.git","ssh_url":"git@github.com:varunpuranik/azure-iot-sdk-csharp.git","clone_url":"https://github.com/varunpuranik/azure-iot-sdk-csharp.git","svn_url":"https://github.com/varunpuranik/azure-iot-sdk-csharp","homepage":null,"size":44207,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Azure:master","ref":"master","sha":"90ff6ece0d2a099d73a3d6190a47d679c8f36022","user":{"login":"Azure","id":6844498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NDQ0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":70936151,"node_id":"MDEwOlJlcG9zaXRvcnk3MDkzNjE1MQ==","name":"azure-iot-sdk-csharp","full_name":"Azure/azure-iot-sdk-csharp","owner":{"login":"Azure","id":6844498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NDQ0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/azure-iot-sdk-csharp","description":"A C# SDK for connecting devices to Microsoft Azure IoT services","fork":false,"url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp","forks_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/forks","keys_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/teams","hooks_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/hooks","issue_events_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/events","assignees_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/tags","blobs_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/languages","stargazers_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/stargazers","contributors_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/contributors","subscribers_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/subscribers","subscription_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/subscription","commits_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/merges","archive_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/downloads","issues_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/labels{/name}","releases_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/deployments","created_at":"2016-10-14T18:18:23Z","updated_at":"2018-09-05T19:38:42Z","pushed_at":"2018-09-05T19:52:30Z","git_url":"git://github.com/Azure/azure-iot-sdk-csharp.git","ssh_url":"git@github.com:Azure/azure-iot-sdk-csharp.git","clone_url":"https://github.com/Azure/azure-iot-sdk-csharp.git","svn_url":"https://github.com/Azure/azure-iot-sdk-csharp","homepage":null,"size":44202,"stargazers_count":179,"watchers_count":179,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":278,"mirror_url":null,"archived":false,"open_issues_count":95,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":278,"open_issues":95,"watchers":179,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls/611"},"html":{"href":"https://github.com/Azure/azure-iot-sdk-csharp/pull/611"},"issue":{"href":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/issues/611"},"comments":{"href":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/issues/611/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls/611/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/pulls/611/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/azure-iot-sdk-csharp/statuses/7af4d85ef7b3c50ba2f350cdf2f230551baf641d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"CIPop"}}