{"id":3586,"date":"2019-05-03T11:32:23","date_gmt":"2019-05-03T11:32:23","guid":{"rendered":"http:\/\/himbap.com\/blog\/?p=3586"},"modified":"2019-05-03T11:32:23","modified_gmt":"2019-05-03T11:32:23","slug":"the-request-channel-timed-out-while-waiting-for-a-reply-after-000159-9687488","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=3586","title":{"rendered":"The request channel timed out while waiting for a reply after 00:01:59.9687488"},"content":{"rendered":"<p><strong>Introduction <\/strong><br \/>\nThis post is about<br \/>\n&#8220;The request channel timed out while waiting for a reply after 00:01:59.9687488. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.&#8221; error, we got this error in our Azure function where we are updating Dynamics 365 CE records. We are going to discussed how we fixed it.<\/p>\n<p><strong>Details<\/strong><br \/>\nWe used following code in our Azure function to connect to Dynamics 365 CE.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n private static OrganizationWebProxyClient GetCRMService(TraceWriter log) {\r\n\r\n  var aadInstance = &quot;https:\/\/login.microsoftonline.com\/&quot;;\r\n  var organizationUrl = &quot;https:\/\/himbap.crm8.dynamics.com&quot;;\r\n\r\n  var tenantId = &quot;8....&quot;;\r\n\r\n  var clientId = &quot;5...&quot;;\r\n\r\n  var clientkey = &quot;qZXgfddd.....&quot;;\r\n\r\n  var clientcred = new ClientCredential(clientId, clientkey);\r\n\r\n  var authenticationContext = new AuthenticationContext(aadInstance + tenantId);\r\n\r\n  var authenticationResult = authenticationContext.AcquireTokenAsync(organizationUrl, clientcred);\r\n\r\n  var requestedToken = authenticationResult.Result.AccessToken;\r\n\r\n  var sdkService = new OrganizationWebProxyClient(GetServiceUrl(organizationUrl), false);\r\n  sdkService.HeaderToken = requestedToken;\r\n  return sdkService;\r\n}\r\n<\/pre>\n<p>Please see our <a href=\"https:\/\/himbap.com\/blog\/?p=3448\">earlier post<\/a> to know, how to connect to Dynamics 365 CE from Azure function. <\/p>\n<p>Recently our Azure function started failing and when we checked logs it was timeout error. It was throwing timout error after two minute as default timeout limit for OrganizationWebProxy is 2 minute. But we can override this setting. We can get OrganizationWebProxyClient by passing following parameters.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic OrganizationWebProxyClient(\r\n    Uri uri,\r\n    TimeSpan timeout,\r\n    Assembly strongTypeAssembly\r\n)\r\n<\/pre>\n<p>Reference: <a href=\"https:\/\/docs.microsoft.com\/en-us\/previous-versions\/dynamicscrm-2016\/developers-guide\/dn832496(v%3Dcrm.8)\">Dynamics 365 CE SDK<\/a><\/p>\n<p>To fix this issue we used following code<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nvar sdkService = new OrganizationWebProxyClient(GetServiceUrl(organizationUrl),new TimeSpan(0, 10, 0), false);\r\n<\/pre>\n<p>We used 10 minute here, but you can change it based on your requirement.<\/p>\n<p><strong>Summary<\/strong><br \/>\nWe learned how to fixed OrganizationWebProxyClient timeout issue by passing TimeSpan parameter. Hope it will help someone. Stay tuned for more Dynamics 365 CE Contents !!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction This post is about &#8220;The request channel timed out while waiting for a reply after 00:01:59.9687488. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.&#8221; error, we got this error in our Azure function where&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=3586\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[491,402],"tags":[705,707,654,706],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3586"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3586"}],"version-history":[{"count":5,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3586\/revisions"}],"predecessor-version":[{"id":3591,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3586\/revisions\/3591"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}