{"action":"created","comment":{"url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls/comments/222919142","pull_request_review_id":161918228,"id":222919142,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMjkxOTE0Mg==","diff_hunk":"@@ -159,25 +190,74 @@ private OrderBook Convert(PriceMessage priceMessage)\n             return result;\n         }\n \n+        private Task ReconnectIfNeeded(ITimerTrigger timer, TimerTriggeredHandlerArgs args, CancellationToken ct)\n+        {\n+            try\n+            {\n+                var isReceivedAtLeastOneOrderBookAtAll = _orderBooksCache.Values.Any();\n+                var isNotReceivedAtLeastOneFreshOrderBookForTheLastInterval =\n+                    !_orderBooksCache.Values.Any(x => DateTime.UtcNow - x.Timestamp < _reconnectIfNeededInterval);\n+                var isNotConnectedFor1MinSinceStart = DateTime.UtcNow - Started > new TimeSpan(0, 0, 1, 0);\n+\n+                var needToReconnect = (isReceivedAtLeastOneOrderBookAtAll && isNotReceivedAtLeastOneFreshOrderBookForTheLastInterval)\n+                    || (!isReceivedAtLeastOneOrderBookAtAll && isNotConnectedFor1MinSinceStart);\n+\n+                _log.Info($\"Reconnect needed: {needToReconnect}. Order books count = {_orderBooksCache.Count}, \" +\n+                          $\"received fresh message since last check = {!isNotReceivedAtLeastOneFreshOrderBookForTheLastInterval}, \" +\n+                          $\"not connected for 1 min since start = {isNotConnectedFor1MinSinceStart}.\");\n+\n+                if (needToReconnect)\n+                    ForceReconnect();\n+            }\n+            catch (Exception ex)","path":"src/Lykke.Service.B2c2Adapter/Services/OrderBooksService.cs","position":132,"original_position":132,"commit_id":"76c656868c28eec6a68cf0fbc2e8c2c39b135e8e","original_commit_id":"6e60140c48c9a8b6258cef097a2f62d94be5bc12","user":{"login":"PeGilo","id":24381304,"node_id":"MDQ6VXNlcjI0MzgxMzA0","avatar_url":"https://avatars1.githubusercontent.com/u/24381304?v=4","gravatar_id":"","url":"https://api.github.com/users/PeGilo","html_url":"https://github.com/PeGilo","followers_url":"https://api.github.com/users/PeGilo/followers","following_url":"https://api.github.com/users/PeGilo/following{/other_user}","gists_url":"https://api.github.com/users/PeGilo/gists{/gist_id}","starred_url":"https://api.github.com/users/PeGilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PeGilo/subscriptions","organizations_url":"https://api.github.com/users/PeGilo/orgs","repos_url":"https://api.github.com/users/PeGilo/repos","events_url":"https://api.github.com/users/PeGilo/events{/privacy}","received_events_url":"https://api.github.com/users/PeGilo/received_events","type":"User","site_admin":false},"body":"ForceReconnect already handles exceptions. Why do we need another one?","created_at":"2018-10-05T07:51:26Z","updated_at":"2018-10-05T07:57:47Z","html_url":"https://github.com/LykkeCity/Lykke.Service.B2c2Adapter/pull/2#discussion_r222919142","pull_request_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls/2","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls/comments/222919142"},"html":{"href":"https://github.com/LykkeCity/Lykke.Service.B2c2Adapter/pull/2#discussion_r222919142"},"pull_request":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls/2","id":220376773,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwMzc2Nzcz","html_url":"https://github.com/LykkeCity/Lykke.Service.B2c2Adapter/pull/2","diff_url":"https://github.com/LykkeCity/Lykke.Service.B2c2Adapter/pull/2.diff","patch_url":"https://github.com/LykkeCity/Lykke.Service.B2c2Adapter/pull/2.patch","issue_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/issues/2","number":2,"state":"open","locked":false,"title":"Synchronized websocket read and write","user":{"login":"AlexeyZelenin","id":4104151,"node_id":"MDQ6VXNlcjQxMDQxNTE=","avatar_url":"https://avatars2.githubusercontent.com/u/4104151?v=4","gravatar_id":"","url":"https://api.github.com/users/AlexeyZelenin","html_url":"https://github.com/AlexeyZelenin","followers_url":"https://api.github.com/users/AlexeyZelenin/followers","following_url":"https://api.github.com/users/AlexeyZelenin/following{/other_user}","gists_url":"https://api.github.com/users/AlexeyZelenin/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexeyZelenin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexeyZelenin/subscriptions","organizations_url":"https://api.github.com/users/AlexeyZelenin/orgs","repos_url":"https://api.github.com/users/AlexeyZelenin/repos","events_url":"https://api.github.com/users/AlexeyZelenin/events{/privacy}","received_events_url":"https://api.github.com/users/AlexeyZelenin/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-10-04T13:27:54Z","updated_at":"2018-10-05T07:57:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cd846b6453f087b8d237424609d2df6facfa0d85","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls/2/commits","review_comments_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls/2/comments","review_comment_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/issues/2/comments","statuses_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/statuses/76c656868c28eec6a68cf0fbc2e8c2c39b135e8e","head":{"label":"LykkeCity:feature_LIQ-678-b2c2-library","ref":"feature_LIQ-678-b2c2-library","sha":"76c656868c28eec6a68cf0fbc2e8c2c39b135e8e","user":{"login":"LykkeCity","id":14153330,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MTUzMzMw","avatar_url":"https://avatars0.githubusercontent.com/u/14153330?v=4","gravatar_id":"","url":"https://api.github.com/users/LykkeCity","html_url":"https://github.com/LykkeCity","followers_url":"https://api.github.com/users/LykkeCity/followers","following_url":"https://api.github.com/users/LykkeCity/following{/other_user}","gists_url":"https://api.github.com/users/LykkeCity/gists{/gist_id}","starred_url":"https://api.github.com/users/LykkeCity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LykkeCity/subscriptions","organizations_url":"https://api.github.com/users/LykkeCity/orgs","repos_url":"https://api.github.com/users/LykkeCity/repos","events_url":"https://api.github.com/users/LykkeCity/events{/privacy}","received_events_url":"https://api.github.com/users/LykkeCity/received_events","type":"Organization","site_admin":false},"repo":{"id":148792680,"node_id":"MDEwOlJlcG9zaXRvcnkxNDg3OTI2ODA=","name":"Lykke.Service.B2c2Adapter","full_name":"LykkeCity/Lykke.Service.B2c2Adapter","private":false,"owner":{"login":"LykkeCity","id":14153330,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MTUzMzMw","avatar_url":"https://avatars0.githubusercontent.com/u/14153330?v=4","gravatar_id":"","url":"https://api.github.com/users/LykkeCity","html_url":"https://github.com/LykkeCity","followers_url":"https://api.github.com/users/LykkeCity/followers","following_url":"https://api.github.com/users/LykkeCity/following{/other_user}","gists_url":"https://api.github.com/users/LykkeCity/gists{/gist_id}","starred_url":"https://api.github.com/users/LykkeCity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LykkeCity/subscriptions","organizations_url":"https://api.github.com/users/LykkeCity/orgs","repos_url":"https://api.github.com/users/LykkeCity/repos","events_url":"https://api.github.com/users/LykkeCity/events{/privacy}","received_events_url":"https://api.github.com/users/LykkeCity/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/LykkeCity/Lykke.Service.B2c2Adapter","description":"B2C2 Adapter","fork":false,"url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter","forks_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/forks","keys_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/teams","hooks_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/hooks","issue_events_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/issues/events{/number}","events_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/events","assignees_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/assignees{/user}","branches_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/branches{/branch}","tags_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/tags","blobs_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/git/refs{/sha}","trees_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/statuses/{sha}","languages_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/languages","stargazers_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/stargazers","contributors_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/contributors","subscribers_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/subscribers","subscription_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/subscription","commits_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/commits{/sha}","git_commits_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/git/commits{/sha}","comments_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/comments{/number}","issue_comment_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/issues/comments{/number}","contents_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/contents/{+path}","compare_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/merges","archive_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/downloads","issues_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/issues{/number}","pulls_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls{/number}","milestones_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/milestones{/number}","notifications_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/labels{/name}","releases_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/releases{/id}","deployments_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/deployments","created_at":"2018-09-14T13:30:32Z","updated_at":"2018-09-14T13:30:37Z","pushed_at":"2018-10-05T07:40:30Z","git_url":"git://github.com/LykkeCity/Lykke.Service.B2c2Adapter.git","ssh_url":"git@github.com:LykkeCity/Lykke.Service.B2c2Adapter.git","clone_url":"https://github.com/LykkeCity/Lykke.Service.B2c2Adapter.git","svn_url":"https://github.com/LykkeCity/Lykke.Service.B2c2Adapter","homepage":null,"size":121,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"LykkeCity:test","ref":"test","sha":"c3cde8be1fa352963896b73544ef5955a2ead2f0","user":{"login":"LykkeCity","id":14153330,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MTUzMzMw","avatar_url":"https://avatars0.githubusercontent.com/u/14153330?v=4","gravatar_id":"","url":"https://api.github.com/users/LykkeCity","html_url":"https://github.com/LykkeCity","followers_url":"https://api.github.com/users/LykkeCity/followers","following_url":"https://api.github.com/users/LykkeCity/following{/other_user}","gists_url":"https://api.github.com/users/LykkeCity/gists{/gist_id}","starred_url":"https://api.github.com/users/LykkeCity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LykkeCity/subscriptions","organizations_url":"https://api.github.com/users/LykkeCity/orgs","repos_url":"https://api.github.com/users/LykkeCity/repos","events_url":"https://api.github.com/users/LykkeCity/events{/privacy}","received_events_url":"https://api.github.com/users/LykkeCity/received_events","type":"Organization","site_admin":false},"repo":{"id":148792680,"node_id":"MDEwOlJlcG9zaXRvcnkxNDg3OTI2ODA=","name":"Lykke.Service.B2c2Adapter","full_name":"LykkeCity/Lykke.Service.B2c2Adapter","private":false,"owner":{"login":"LykkeCity","id":14153330,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MTUzMzMw","avatar_url":"https://avatars0.githubusercontent.com/u/14153330?v=4","gravatar_id":"","url":"https://api.github.com/users/LykkeCity","html_url":"https://github.com/LykkeCity","followers_url":"https://api.github.com/users/LykkeCity/followers","following_url":"https://api.github.com/users/LykkeCity/following{/other_user}","gists_url":"https://api.github.com/users/LykkeCity/gists{/gist_id}","starred_url":"https://api.github.com/users/LykkeCity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LykkeCity/subscriptions","organizations_url":"https://api.github.com/users/LykkeCity/orgs","repos_url":"https://api.github.com/users/LykkeCity/repos","events_url":"https://api.github.com/users/LykkeCity/events{/privacy}","received_events_url":"https://api.github.com/users/LykkeCity/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/LykkeCity/Lykke.Service.B2c2Adapter","description":"B2C2 Adapter","fork":false,"url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter","forks_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/forks","keys_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/teams","hooks_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/hooks","issue_events_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/issues/events{/number}","events_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/events","assignees_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/assignees{/user}","branches_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/branches{/branch}","tags_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/tags","blobs_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/git/refs{/sha}","trees_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/statuses/{sha}","languages_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/languages","stargazers_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/stargazers","contributors_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/contributors","subscribers_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/subscribers","subscription_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/subscription","commits_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/commits{/sha}","git_commits_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/git/commits{/sha}","comments_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/comments{/number}","issue_comment_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/issues/comments{/number}","contents_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/contents/{+path}","compare_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/merges","archive_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/downloads","issues_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/issues{/number}","pulls_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls{/number}","milestones_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/milestones{/number}","notifications_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/labels{/name}","releases_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/releases{/id}","deployments_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/deployments","created_at":"2018-09-14T13:30:32Z","updated_at":"2018-09-14T13:30:37Z","pushed_at":"2018-10-05T07:40:30Z","git_url":"git://github.com/LykkeCity/Lykke.Service.B2c2Adapter.git","ssh_url":"git@github.com:LykkeCity/Lykke.Service.B2c2Adapter.git","clone_url":"https://github.com/LykkeCity/Lykke.Service.B2c2Adapter.git","svn_url":"https://github.com/LykkeCity/Lykke.Service.B2c2Adapter","homepage":null,"size":121,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls/2"},"html":{"href":"https://github.com/LykkeCity/Lykke.Service.B2c2Adapter/pull/2"},"issue":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/issues/2"},"comments":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.B2c2Adapter/statuses/76c656868c28eec6a68cf0fbc2e8c2c39b135e8e"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"PeGilo"}}