I have a WCF client application that transmits data to a 3rd party vendor with a large .Net collection (25 mb).
The client always times out, but the vendor's service keeps running to completion.
I need the client to get a response back from the vendor service so I can go on with the next collection.
I have placed the following code at the beginning of my client application, but it still does no good. I get the same result.
"serviceClient" is my client app and "hhOutBoundClient" is the Vendor's service.
ShopProcessService.ShopProcessServiceClient serviceClient = new ShopProcessService.ShopProcessServiceClient();
HHOutBoundService.RyderServiceClient hhOutBoundClient = new HHOutBoundService.RyderServiceClient();
var customBinding = new CustomBinding(serviceClient.Endpoint.Binding);
var transportElement = customBinding.Elements.Find<HttpTransportBindingElement>();
transportElement.KeepAliveEnabled = true;
serviceClient.Endpoint.Binding = customBinding;
Can someone please inform me how I can keep the session alive for my client so it won't time out?
Here is my client config file. Mine is the one with the wsHttpBinding.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_RyderService" closeTimeout="02:00:00"
openTimeout="02:00:00" receiveTimeout="02:00:00" sendTimeout="02:00:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
messageEncoding="Text">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="Basic" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="WsHttpBinding_IShopProcessService" closeTimeout="02:00:00"
openTimeout="02:00:00" receiveTimeout="02:00:00" sendTimeout="02:00:00"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
<binding name="WSHttpBinding_IShopProcessService">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<diagnostics wmiProviderEnabled="true">
<messageLogging logMessagesAtTransportLevel="true" logMessagesAtServiceLevel="true" logMalformedMessages="true" logEntireMessage="true" maxSizeOfMessageToLog="2147483647" maxMessagesToLog="100" />
</diagnostics>
<client>
<endpoint address="https://abc.xyz.com/RyderDataPortal/RyderService.svc"
behaviorConfiguration="BasicHttpBinding_RyderService" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_RyderService" contract="HHOutBoundService.IRyderService"
name="BasicHttpBinding_RyderService" />
<endpoint address="http://999.999.9.999/RyderShopProcessService/ShopProcessService.svc"
binding="wsHttpBinding" bindingConfiguration="WsHttpBinding_IShopProcessService"
contract="ShopProcessService.IShopProcessService" name="WsHttpBinding_IShopProcessService" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="WsHttpBinding_IShopProcessService">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
<behavior name="webhttp">
<webHttp/>
</behavior>
<behavior name="BasicHttpBinding_RyderService">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
I've tried everything from setting reliablemessaging properties in the binding in conjunction with the above source code in the client and vice-versa; None of it works.
I would very much appreciate somebody who has experienced this before and has come up with a definite solution.
Thanks in advance.
Exact error msg:
Message: { strMessage = Class: ShopProcessServiceClient
Method: Main
Error: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.
InnerException: System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. ---> 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
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.TlsStream.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)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Source: mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Ryder.ShopProcessService.Outbound.HHOutBoundService.IRyderService.PostFuelTankConversionCharts(TankConversionChartCollection conversion_charts)
at Ryder.ShopProcessService.Outbound.HHOutBoundService.RyderServiceClient.PostFuelTankConversionCharts(TankConversionChartCollection conversion_charts) in c:\Development\SMO_VS_2013\HHOutboundClient\SOASolutionA\Ryder.ShopProcessService.Outbound\Service References\HHOutBoundService\Reference.cs:line 2856
at Ryder.ShopProcessService.Outbound.ShopProcessServiceClient.Main(String[] args) in c:\Development\SMO_VS_2013\HHOutboundClient\SOASolutionA\Ryder.ShopProcessService.Outbound\ShopProcessServiceClient.cs:line 87, strProject = Ryder.ShopProcessService.Outbound, strRemedyTktResponse = INC000000091926 }
Extended Properties: