Check out the latest Sales updates!Learn about the key capabilities and features of Dynamics 365 Sales and experience some of the new features.
Download overview guide | Watch Sales video
2020 release wave 1Discover the latest updates and new features to Dynamics 365 planned through September 2020
Release overview guides and videos Release Plan | Preview 2020 Release Wave 1 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
We are using OrganizationServiceProxy object (created by using the Microsoft.Xrm.Tooling.Connector.CrmServiceClient) to access CRM in our web service functions. From time to time, we would encounter this "The underlying connection was closed: A connection that was expected to be kept alive was closed by the server." WebException. Can anyone give a solution to solve this problem?
Searching on internet, it is suggested that setting the connection KeepAlive to false can solve the problem. However, the OrganizationServiceProxy does not provide a way to change this property. Can somebody help?
There's not a direct KeepAlive property that you can use. The general pattern that I use is to catch the exception and recreate the OrganizationServiceProxy object.
Alternatively, as the main reason for the connection to be close is that the security token has expired, you can check if the security token is about to expire (via the SecurityTokenResponse property), and if so, reauthenticate using the Authenticate method.
Thanks David for the suggestion.
We already implemented the auto refreshing token mechanism. So security token expiration may not be the reason.
Can the OrganizationServiceProxy object be used again after the failure? If we have to create a new proxy object, it will be too much hassle because the object is not passed in process functions by reference, and it is used across several places within one business process function.
Business Applications communities