Hello All, Again some issue with Two technologies (WCF and Entity framework).
I have a service method which return entity object with child entity as a collection. But when it returning response to end client it is throwing something out of mind exception. it says
“CommunicationException get thrown: An error occurred while receiving the HTTP response to http://localhost:8080/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.”
Firstly, I didn’t understood the exception that what is happening. I researched through fiddler and other tools but i did not got any proper error details. nothing was going on way.
So I used a trick to serialize the returning collection prior to sending to client. And my trick got worked, When serializing the object I received “
A circular reference was detected while serializing an object “.
So after searching on net i found that navigation property inside child element for parent entity was creating the issue. It was serializing child and parent entities again and again.
So after removing parent navigation property from child entity I was able to return parent and child records without any error.
Please note that this problem will only occur when you are serializing the entity object.
Please post me with such issues which you have faced with WCF and Entity framework so it will help other who are facing the issue & wasting their time researching the error.
Entity framework and WCF service nightmare : “The underlying connection was closed: An unexpected error occurred on a receive. —> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host”
I started playing on WCF with Entity fx 5 recently. I got a requirement where I had to fetch parent and child record based on provided id.
I started to write a simple linq query which will return me a row with parent and child record. everything was on way to build and test service. The nightmare just started when i faced “The underlying connection was closed: An unexpected error occurred on a receive. —> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.”
I started searching on net but could not got the correct resolution. After 3 hours continuous research given me an answer by deeply studying datacontext object.
There is a property named “ProxyCreationEnabled” which creates the proxy for an object which will help in tracking and lazy loading operations. When it is set to “true” it will prevent object from serializing and that’s why I was facing the above error.
So by setting it to “false” made my query started working. Also to boost the performance of queries you should set it “false”.
You can find it in context as
contextObj.Configuration.ProxyCreationEnabled = false;