Reputation: 21
I am having issues with my wcf service while testing with WCF Client. When I debug, I see that data comes back from the funcion but it errors out during response. Can someone help me figure out what I am missing?
Here is my service and config file:
public List<PO> GetAllPOs()
{
var data = new List<PO>();
try
{
var manager = new EntityReaderManager<PO>(ConfigurationManager.AppSettings("FilemakerDB"]);
data = manager.GetEntityList();
}
catch (Exception ex)
{
ILogger logger = new Logger(typeof(FilemakerDataService));
logger.Error(ex.Message);
}
return data;
}
Here is the config file:
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"
maxSizeOfMessageToLog="2147483647" />
<endToEndTracing propagateActivity="true" activityTracing="false"
messageFlowTracing="true" />
</diagnostics>
<bindings>
<wsHttpBinding>
<binding name="Custom.WSHTTPBinding.Configuration" closeTimeout="10:10:00"
openTimeout="10:10:00" receiveTimeout="10:10:00" sendTimeout="10:10:00"
maxBufferPoolSize="655360" maxReceivedMessageSize="655360">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
<services>
<service behaviorConfiguration="Custom.ServiceBehavior" name="AerWorldwide.Service.Web.FilemakerData.FilemakerDataService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="Custom.WSHTTPBinding.Configuration"
name="Custom.WSHTTPBinding.Configuration" contract="AerWorldwide.Service.Web.FilemakerData.IFilemakerDataService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Custom.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Error:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
Inner Exception: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
Upvotes: 1
Views: 8242
Reputation: 7876
First of all enable Tracing on your Service and see what is the cause for exception.
Also you would consider increasing ReaderQuotas on your server and client side so that larger data is passed without any problem. Sample shown below:
<wsHttpBinding>
<binding name="Custom.WSHTTPBinding.Configuration" closeTimeout="10:10:00"
openTimeout="10:10:00" receiveTimeout="10:10:00" sendTimeout="10:10:00"
maxBufferPoolSize="655360" maxReceivedMessageSize="655360">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</wsHttpBinding>
Also i see in your code that you are passing the object fetched by entity framework directly. There are situations where the entity framework objects dont get deserialzed and might cause exception. Create a simple POCO and then populate the fetched data and return the POCO.
Upvotes: 4