Reading data over http api sometimes returns the wrong result

We have a rare and interesting problem when working with the http api of EventStore. In our process we have multiple subscriptions each in their own thread, that each iterate over an event stream and pipe the events to their respective handlers. Each subscription has it’s own .net HttpClient for reading slices (with long polling) and another one for reading the actual events. We are reading the slices as atom xml so we can deserialize them with the SyndicationFeed class, as this seems to be a bit faster than json deserialization. Now to the interesting part: very rarely, like once in a couple of days, the HttpClient that should read the xml slices returns a json data from a specific event. So now the XmlReader that provides the data to SyndicationFeed rightfully throws an XmlException. We added logging over the time to find out why the XmlException was thrown and after not being able to figure out what causes the problem we added retry logic that just repeats the request, which basically works. It seems that one HttpClient instance receives the response from an other instance, which should be impossible I think, as each instance afaik holds its own tcp connections that shouldn’t be shared among other instances.

To be clear, we don’t know if the problem is on EventStore’s side or in our client code, because the problem happens so seldom that we were not able to reproduce while running Fiddler.

Did somebody ever have a similar issue? Does anybody think that using the HttpClient together with http pipelining and long polling could cause these problems? Are there good ways to analyze a problem like that?

Thanks a lot!

Sebastian

setup a log of your http requests (wireshark is good) and include the bad ones.

To be fair we didn't write http client :slight_smile: but we are happy to help
debug the issue.

Thanks Greg, this is true, just thought somebody might have had the same issue and found a solution. As far as I can see HttpClient is thread safe and doesn’t share connections, at least that is what the MSDN documentation says. We will try to find out more with wireshark, but if somebody has any ideas in the meantime, we would be happy to hear them.

Thanks,

Sebastian

For me the surface area is just too big which is why I ask for a
wireshark, nothing about you personally :slight_smile:

Understandable :slight_smile: Basically the question boils down to if it is somehow possible that HttpClient isn’t threadsafe after all, or if there could be problems with http pipelining used together with long polling requests.
For now we will perform long running tests in a new VM + wireshark. I think I will also post a slightly rephrased question on SO, but I will report back if I find out something new.

Thanks,

Sebastian