tags:

views:

27

answers:

2
CommunicationException was unhandled by user code
The socket connection was aborted. This could be caused by an error processing your message
or a receive timeout being exceeded by the remote host, or an underlying network resource
issue. Local socket timeout was '02:48:04.9840000'.

I've been testing this application for months and have just seen this error after making a small change to one of the services. It's only a few seconds, so I don't think it's a timeout issue.

InnerException: System.IO.IOException : The read operation failed, see inner exception

(Inner) InnerException: System.Net.Sockets.SocketException - An existing connection was forcibly closed by the remote host.

Any suggestions are greatly appreciated!

Thanks in advance

+1  A: 

Typically I have seen this error when the opposite party does not cleanly shut down the connection. If on the client side you have a class that inherits from ClientBase then you should call Close when you are finished with the service (actually ClientBase implements IDisposable so you can use a using statement). If you are using a ChannelFactory to create the connection to the service the result is a proxy that implements the contract but also implements ICommunicationObject; you should call close on this when you are finished. On the service side things are not the same, the session (and therefore the underlying socket) is managed by the client. If the service is dropping the socket most likely this is the result of an error, in which case Music Magi's suggestion is a good one. Microsoft talks about how to go about this here. Note that to get a clear picture of what is going on you may have to set up tracing for both the client and the service. In order to view the traces you would use SvcTraceViewer which should be in the 'Program Files\Microsoft SDKs\Windows\v6.0A\bin' or 'Program Files\Microsoft SDKs\Windows\v7.0A\bin' folder. If you have to trace both the client and the service you can open both files together in SvcTraceViewer using the File / Add menu.

Steve Ellinger
+1  A: 

You are most likely running into quota issues like the MaxReceivedMessageSize, MaxArrayLength, MaxStringContentLength defined in the binding.

You can also have a look at the MaxItemsInObjectGraph attribute available in the behaviors.

Johann Blais