web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Using HttpClient from plug-in - used to be fine but now gives Overlapped I/O errors?

(1) ShareShare
ReportReport
Posted on by 58

Just wondering if anyone else had hit this.

We have a plug-in that calls a custom web-service. (The web service is our own, developed in MVC4 and deployed on a VM in Azure, say.)

The call is made using HttpClient and Postasync.    (Since you can't do async in a plug-in, there's a ".Result" on there to make the thread wait.)

This all ran perfectly reliably in several Dynamics 365 Online CRM tenants / orgs for several months.

Mid-December, something must have changed somewhere because without our having touched anything we started getting intermittent exceptions in the plug-in.  These are network-stack errors and they basically all mention Overlapped I/O and something not being in a signalled state.

An example stacktrace might be...

System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: Overlapped I/O event is not in a signaled state. ---> System.Net.Sockets.SocketException: Overlapped I/O event is not in a signaled state

... though sometimes it's slightly different and complains that the client closed the connection.  (I've also seen a server-closed-the-connection version, but I'm pretty sure that was only after I'd tried tweaking my code.)

The *server* doesn't always log the error in its IIS log but when it does it's a "500 0 64" error.  I've done a couple of failed request tracing traces and they suggested that the client was closing the connection before all the data had been received.

It looks to me like either Microsoft have changed something on the CRM end so that the Postaync request or its underlying Windows network connection is getting forcibly killed off or disconnected almost as soon as it starts, or else they've changed something in the network and we've got some switch or firewall killing things.

We've tried optimising and changing the connection options available to us via the HttpClient and they don't seem to make anything any more or less reliable. 

We've mitigated for now with a retry loop - if we keep trying, eventually the call succeeds - I've seen it take up to about 100 attempts (!) though usually it's < 10.  (The web-service call actually takes a number of seconds to process when it works successfully - it's connecting on to SharePoint - but the failures all seem to happen after only a small number of milliseconds, so 100 retries doesn't actually add too much to the time.)

I've got a case open with Microsoft, but just wondered if anyone else is using HttpClient and having problems only recently.  (Just remembered, we did actually use it in another, simpler call and experienced intermittent unreliability there too.  I *think* switching that call to use WebClient has fixed things, though it's not been heavily tested and I still saw a "Task Canceled" error that I haven't got to the bottom of yet.)

Feel free to comment if you've hit the issue too!  

Thanks.

MWM

*This post is locked for comments

I have the same question (0)
  • Eric benco Profile Picture
    320 on at

    We are seeing the same issue.   I just started looking into this.  Was Microsoft able to determine the root cause or did you stick with retry loop?

  • Suggested answer
    mwm Profile Picture
    58 on at

    Hi Eric,

    I spent a while trying to encourage Microsoft to find us something useful.  Didn't manage it.

    We lived with the retry loop for a while but our customers would still see occasional errors even with high retry-limits. 

    We eventually migrated everything "back" to use WebClient which (presumably because of its synchronous nature) doesn't seem to exhibit the issue.  Luckily, none of our use-cases are sufficiently high load that thread availability seems to have been an issue for us.

    Just one of those things you have to put up with when you're not in charge of the whole stack, I guess...

    Cheers,

    Mike.

  • Eric benco Profile Picture
    320 on at

    I did change the plugin that was giving us problems under heavy to use WebClient and that basically gave us a new error of 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'   The new error would only happen sporadically (1 out of 100) just like Overlapped I/O Event error.   I added some timings around the call to .UploadString and it would always fail if the request took longer then 19 seconds to complete.  I ended up putting it in a retry loop....so sad

  • tayurskiy Profile Picture
    20 on at

    Same issue here. Have a high priority case opened with Microsoft but no resolution yet. Will update this thread is there is a solution.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans