WCF Asynchronous Call - Exception at eventhandler
I am making Asynchronous call to WCF method with eventhandler. I am getting an error at 'EventAddCallback' event and 'e.Error' shows the following error. Any knows why? I adding sample code, error info, tracing info and options I tried..
System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid. Check InnerException for exception details. ---> System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to https://demosite.com/ourservice.asmx. 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. ---> 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: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
I enabled the tracing and it shows..
System.ServiceModel.CommunicationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
An error occurred while receiving the HTTP response to https://demosite.com/ourservice.asmx. 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.
-->System.Net.WebException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-->The underlying connection was closed: An unexpected error occurred on a receive.
------>System.IO.IOException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
------>Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
---------->System.Net.Sockets.SocketException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
---------->An existing connection was forcibly closed by the remote host
Options I tried..
1. Increased
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
2. Enabled 'Keep Alive', increased buffer size(s)
<httpsTransport maxReceivedMessageSize="2147483647" keepAliveEnabled="true" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" />
3. added endpointBehaviors
<endpointBehaviors>
<behavior name="demo">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
class Program
{
static ManualResetEvent closeapp = new ManualResetEvent(false);
static void Main(string[] args)
{
wcfclient.AddCompleted += new EventHandler<AddCompletedEventArgs>(EventAddCallback);
wcfclient.AddAsync(employees);
closeapp.WaitOne();
}
static void EventAddCallback(object sender, AddCompletedEventArgs e)
{
try
{
if (e.Error != null)
{
wcfclient.Close();
closeapp.Set();
}else
{
//Continue with other calls.
}
}
catch (Exception ex) {
throw ex;
}
}
}
You have th wrong security vindig for the binding. Either you must switch to http (which you probably can't due to server setup) or you should switch to transport Security in the client binding config.