shahbour | 26 Jun 2012 14:49
Picon

WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Hello

I got an WCF service that is running except at some time if the client send
a request then close his program directly , ending the session the WCF
console application crashes with below error 

[0x7f0b42f55700:] EXCEPTION handling: System.Net.Sockets.SocketException:
Connection reset by peer
[0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure
[0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure

Unhandled Exception: System.IO.IOException: Read failure --->
System.Net.Sockets.SocketException: Connection reset by peer
  at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32 offset,
Int32 size, SocketFlags flags) [0x000ad] in
/usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/Socket.cs:1606
  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32
offset, Int32 size) [0x00067] in
/usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:399
  --- End of inner exception stack trace ---
  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32
offset, Int32 size) [0x00078] in
/usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:401
  at System.Net.RequestStream.Read (System.Byte[] buffer, Int32 offset,
Int32 count) [0x0003c] in
/usr/local/src/mono-2.11.1/mcs/class/System/System.Net/RequestStream.cs:142
  at System.IO.StreamReader.ReadBuffer () [0x00012] in
/usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:394
  at System.IO.StreamReader.Read (System.Char[] buffer, Int32 index, Int32
count) [0x00062] in
(Continue reading)

Rob Wilkens | 26 Jun 2012 15:59
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

I'm wondering if this is a bug.....  And maybe a report should be filed....  Sounds like a similar problem i looked at recently, but that bug was different because the sample code in the bug report also crashed in windows.

According to:  http://www.codeproject.com/Articles/8580/How-to-detect-a-connection-loss-in-Net-Sockets

The way to detect a remotely closed connection is to check if Socket.Receive (which, incidentally, is the topmost thing on the stack below) returns 0 or fewer bytes -- so you wouldn't expect an exception, instead you would expect a 0 return for number of bytes read.

This would seem to match:

http://msdn.microsoft.com/en-us/library/w3xtz6a5.aspx

Which says:

" If the remote host shuts down the Socket connection with the Shutdown method, and all available data has been received, the Receive method will complete immediately and return zero bytes."

And also says that SocketException is only raised under certain conditions, the only almost valid match is:

"An operating system error occurs while accessing the Socket."

But i don't think connection reset by peer is necessarily an operating system exception, it's rather a state of connection indicating we're disconnected, hence we should be returning zero, not raising an exception.

-Rob

On 06/26/2012 08:49 AM, shahbour wrote:
Hello I got an WCF service that is running except at some time if the client send a request then close his program directly , ending the session the WCF console application crashes with below error [0x7f0b42f55700:] EXCEPTION handling: System.Net.Sockets.SocketException: Connection reset by peer [0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure [0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure Unhandled Exception: System.IO.IOException: Read failure ---> System.Net.Sockets.SocketException: Connection reset by peer at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32 offset, Int32 size, SocketFlags flags) [0x000ad] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/Socket.cs:1606 at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00067] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:399 --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00078] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:401 at System.Net.RequestStream.Read (System.Byte[] buffer, Int32 offset, Int32 count) [0x0003c] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net/RequestStream.cs:142 at System.IO.StreamReader.ReadBuffer () [0x00012] in /usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:394 at System.IO.StreamReader.Read (System.Char[] buffer, Int32 index, Int32 count) [0x00062] in /usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:471 at Mono.Xml2.XmlTextReader.ReadTextReader (Int32 remained) [0x0004f] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1256 at Mono.Xml2.XmlTextReader.PeekChar () [0x00047] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1210 at Mono.Xml2.XmlTextReader.ReadContent () [0x0003f] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1310 at Mono.Xml2.XmlTextReader.Read () [0x00141] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:626 at System.Xml.XmlTextReader.Read () [0x0006b] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader2.cs:564 at System.Xml.XmlSimpleDictionaryReader.Read () [0x00000] in /usr/local/src/mono-2.11.1/mcs/class/System.Runtime.Serialization/System.Xml/XmlSimpleDictionaryReader.cs:253 at System.Xml.XmlReader.MoveToContent () [0x00050] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlReader.cs:574 at System.ServiceModel.Channels.XmlReaderMessage.ReadEnvelopeStart () [0x00000] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:146 at System.ServiceModel.Channels.XmlReaderMessage..ctor (System.ServiceModel.Channels.MessageVersion version, System.Xml.XmlDictionaryReader reader, Int32 maxSizeOfHeaders) [0x00026] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:70 at System.ServiceModel.Channels.Message.CreateMessage (System.Xml.XmlDictionaryReader envelopeReader, Int32 maxSizeOfHeaders, System.ServiceModel.Channels.MessageVersion version) [0x00022] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:427 at System.ServiceModel.Channels.TextMessageEncoder.ReadMessage (System.IO.Stream stream, Int32 maxSizeOfHeaders, System.String contentType) [0x00011] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs:87 at System.ServiceModel.Channels.Http.HttpReplyChannel.CreatePostMessage (System.ServiceModel.Channels.Http.HttpContextInfo ctxi) [0x00081] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs:229 at System.ServiceModel.Channels.Http.HttpReplyChannel.TryReceiveRequest (TimeSpan timeout, System.ServiceModel.Channels.RequestContext& context) [0x000aa] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs:172 at System.ServiceModel.Channels.ReplyChannelBase.<BeginTryReceiveRequest>m__10 (TimeSpan tout, System.ServiceModel.Channels.RequestContext& ctx) [0x0002f] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReplyChannelBase.cs:126 I couldn't figure out how to check the connection status before trying to ReadMessage or CreatePostMessage functions. Any Help ?? -- View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173.html Sent from the Mono - Dev mailing list archive at Nabble.com. _______________________________________________ Mono-devel-list mailing list Mono-devel-list <at> lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list


_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
Rob Wilkens | 26 Jun 2012 16:12
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Ammendment to previous reply:

http://stackoverflow.com/questions/1434451/connection-reset-by-peer

Also seems to indicate that connection reset by peer is not a clean connection close, but rather a 'hang up' (immediate disconnect) by the remote end.  So maybe it's not a mono bug.

Have you tried, in your console application, using exception handling to detect the Socket Exception, then handling as appropriate in your console application (such as restarting, if that's what you need to do).

-Rob

On 06/26/2012 08:49 AM, shahbour wrote:
Hello I got an WCF service that is running except at some time if the client send a request then close his program directly , ending the session the WCF console application crashes with below error [0x7f0b42f55700:] EXCEPTION handling: System.Net.Sockets.SocketException: Connection reset by peer [0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure [0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure Unhandled Exception: System.IO.IOException: Read failure ---> System.Net.Sockets.SocketException: Connection reset by peer at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32 offset, Int32 size, SocketFlags flags) [0x000ad] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/Socket.cs:1606 at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00067] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:399 --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00078] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:401 at System.Net.RequestStream.Read (System.Byte[] buffer, Int32 offset, Int32 count) [0x0003c] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net/RequestStream.cs:142 at System.IO.StreamReader.ReadBuffer () [0x00012] in /usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:394 at System.IO.StreamReader.Read (System.Char[] buffer, Int32 index, Int32 count) [0x00062] in /usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:471 at Mono.Xml2.XmlTextReader.ReadTextReader (Int32 remained) [0x0004f] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1256 at Mono.Xml2.XmlTextReader.PeekChar () [0x00047] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1210 at Mono.Xml2.XmlTextReader.ReadContent () [0x0003f] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1310 at Mono.Xml2.XmlTextReader.Read () [0x00141] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:626 at System.Xml.XmlTextReader.Read () [0x0006b] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader2.cs:564 at System.Xml.XmlSimpleDictionaryReader.Read () [0x00000] in /usr/local/src/mono-2.11.1/mcs/class/System.Runtime.Serialization/System.Xml/XmlSimpleDictionaryReader.cs:253 at System.Xml.XmlReader.MoveToContent () [0x00050] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlReader.cs:574 at System.ServiceModel.Channels.XmlReaderMessage.ReadEnvelopeStart () [0x00000] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:146 at System.ServiceModel.Channels.XmlReaderMessage..ctor (System.ServiceModel.Channels.MessageVersion version, System.Xml.XmlDictionaryReader reader, Int32 maxSizeOfHeaders) [0x00026] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:70 at System.ServiceModel.Channels.Message.CreateMessage (System.Xml.XmlDictionaryReader envelopeReader, Int32 maxSizeOfHeaders, System.ServiceModel.Channels.MessageVersion version) [0x00022] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:427 at System.ServiceModel.Channels.TextMessageEncoder.ReadMessage (System.IO.Stream stream, Int32 maxSizeOfHeaders, System.String contentType) [0x00011] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs:87 at System.ServiceModel.Channels.Http.HttpReplyChannel.CreatePostMessage (System.ServiceModel.Channels.Http.HttpContextInfo ctxi) [0x00081] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs:229 at System.ServiceModel.Channels.Http.HttpReplyChannel.TryReceiveRequest (TimeSpan timeout, System.ServiceModel.Channels.RequestContext& context) [0x000aa] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs:172 at System.ServiceModel.Channels.ReplyChannelBase.<BeginTryReceiveRequest>m__10 (TimeSpan tout, System.ServiceModel.Channels.RequestContext& ctx) [0x0002f] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReplyChannelBase.cs:126 I couldn't figure out how to check the connection status before trying to ReadMessage or CreatePostMessage functions. Any Help ?? -- View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173.html Sent from the Mono - Dev mailing list archive at Nabble.com. _______________________________________________ Mono-devel-list mailing list Mono-devel-list <at> lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list


_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
shahbour | 26 Jun 2012 19:43
Picon

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Hello Rob

You are correct this happen when the client (Silverlight application)
request a query and then close the browser immediately before getting the
response .

I tried to handle the error in my Console Application (i implemented
IErrorHandler in WCF) to handle all errors still no luck.

Also i did Try Catch on my service method but still at some point the
Console application crash .

BR
Shahbour

--
View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173p4650182.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
Rob Wilkens | 26 Jun 2012 22:04
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

WCF ("Windows" communication foundation) sounds remarkably platform
specific, but without knowing anything else, i bet they implemented it
in mono anyway....

http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.ierrorhandler.aspx

Says that the IErrorHandler should return a value indicating whether
the dispatcher aborts the session or not. I"m curious if you're
returning true or false in the case of a SocketException indicating
the connection was reset by peer?  I might suggest returning a value
indicating that you do want to abort the session (but not the whole
program) at that point, because this will allow it, in theory, to exit
that session's processing without necessarily crashing the whole
application.

-Rob

On Tue, Jun 26, 2012 at 1:43 PM, shahbour <shahbour <at> gmail.com> wrote:
> Hello Rob
>
> You are correct this happen when the client (Silverlight application)
> request a query and then close the browser immediately before getting the
> response .
>
> I tried to handle the error in my Console Application (i implemented
> IErrorHandler in WCF) to handle all errors still no luck.
>
> Also i did Try Catch on my service method but still at some point the
> Console application crash .
>
> BR
> Shahbour
>
> --
> View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173p4650182.html
> Sent from the Mono - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list <at> lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
Maciej Paszta | 27 Jun 2012 07:16
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

I don't think IErrorHandler would work in this case. Look at the stack
trace - you are unable to catch exception in any way since, the
connection is made in a separate thread (at least I suppose so looking
at the stack trace, specifically
System.ServiceModel.Channels.ReplyChannelBase.<BeginTryReceiveRequest>m__10).
Check whether your application behaves the same way on the .NET, if
not just make a bug report.

On Tue, Jun 26, 2012 at 2:49 PM, shahbour <shahbour <at> gmail.com> wrote:
> Hello
>
> I got an WCF service that is running except at some time if the client send
> a request then close his program directly , ending the session the WCF
> console application crashes with below error
>
>
> [0x7f0b42f55700:] EXCEPTION handling: System.Net.Sockets.SocketException:
> Connection reset by peer
> [0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure
> [0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure
>
> Unhandled Exception: System.IO.IOException: Read failure --->
> System.Net.Sockets.SocketException: Connection reset by peer
>  at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32 offset,
> Int32 size, SocketFlags flags) [0x000ad] in
> /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/Socket.cs:1606
>  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32
> offset, Int32 size) [0x00067] in
> /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:399
>  --- End of inner exception stack trace ---
>  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32
> offset, Int32 size) [0x00078] in
> /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:401
>  at System.Net.RequestStream.Read (System.Byte[] buffer, Int32 offset,
> Int32 count) [0x0003c] in
> /usr/local/src/mono-2.11.1/mcs/class/System/System.Net/RequestStream.cs:142
>  at System.IO.StreamReader.ReadBuffer () [0x00012] in
> /usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:394
>  at System.IO.StreamReader.Read (System.Char[] buffer, Int32 index, Int32
> count) [0x00062] in
> /usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:471
>  at Mono.Xml2.XmlTextReader.ReadTextReader (Int32 remained) [0x0004f] in
> /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1256
>  at Mono.Xml2.XmlTextReader.PeekChar () [0x00047] in
> /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1210
>  at Mono.Xml2.XmlTextReader.ReadContent () [0x0003f] in
> /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1310
>  at Mono.Xml2.XmlTextReader.Read () [0x00141] in
> /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:626
>  at System.Xml.XmlTextReader.Read () [0x0006b] in
> /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader2.cs:564
>  at System.Xml.XmlSimpleDictionaryReader.Read () [0x00000] in
> /usr/local/src/mono-2.11.1/mcs/class/System.Runtime.Serialization/System.Xml/XmlSimpleDictionaryReader.cs:253
>  at System.Xml.XmlReader.MoveToContent () [0x00050] in
> /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlReader.cs:574
>  at System.ServiceModel.Channels.XmlReaderMessage.ReadEnvelopeStart ()
> [0x00000] in
> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:146
>  at System.ServiceModel.Channels.XmlReaderMessage..ctor
> (System.ServiceModel.Channels.MessageVersion version,
> System.Xml.XmlDictionaryReader reader, Int32 maxSizeOfHeaders) [0x00026] in
> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:70
>  at System.ServiceModel.Channels.Message.CreateMessage
> (System.Xml.XmlDictionaryReader envelopeReader, Int32 maxSizeOfHeaders,
> System.ServiceModel.Channels.MessageVersion version) [0x00022] in
> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:427
>  at System.ServiceModel.Channels.TextMessageEncoder.ReadMessage
> (System.IO.Stream stream, Int32 maxSizeOfHeaders, System.String contentType)
> [0x00011] in
> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs:87
>  at System.ServiceModel.Channels.Http.HttpReplyChannel.CreatePostMessage
> (System.ServiceModel.Channels.Http.HttpContextInfo ctxi) [0x00081] in
> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs:229
>  at System.ServiceModel.Channels.Http.HttpReplyChannel.TryReceiveRequest
> (TimeSpan timeout, System.ServiceModel.Channels.RequestContext& context)
> [0x000aa] in
> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs:172
>  at
> System.ServiceModel.Channels.ReplyChannelBase.<BeginTryReceiveRequest>m__10
> (TimeSpan tout, System.ServiceModel.Channels.RequestContext& ctx) [0x0002f]
> in
> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReplyChannelBase.cs:126
>
> I couldn't figure out how to check the connection status before trying to
> ReadMessage or CreatePostMessage functions.
>
> Any Help ??
>
>
> --
> View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173.html
> Sent from the Mono - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list <at> lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

--

-- 
Maciej Paszta
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
Rob Wilkens | 27 Jun 2012 12:32
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

I apologize, I was under the probably mistaken impression that those
"EXCEPTION handling:" messages were coming from the IErrorHandler he was
talking about. 

-Rob

On 06/27/2012 01:16 AM, Maciej Paszta wrote:
> I don't think IErrorHandler would work in this case. Look at the stack
> trace - you are unable to catch exception in any way since, the
> connection is made in a separate thread (at least I suppose so looking
> at the stack trace, specifically
> System.ServiceModel.Channels.ReplyChannelBase.<BeginTryReceiveRequest>m__10).
> Check whether your application behaves the same way on the .NET, if
> not just make a bug report.
>
> On Tue, Jun 26, 2012 at 2:49 PM, shahbour <shahbour <at> gmail.com> wrote:
>> Hello
>>
>> I got an WCF service that is running except at some time if the client send
>> a request then close his program directly , ending the session the WCF
>> console application crashes with below error
>>
>>
>> [0x7f0b42f55700:] EXCEPTION handling: System.Net.Sockets.SocketException:
>> Connection reset by peer
>> [0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure
>> [0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure
>>
>> Unhandled Exception: System.IO.IOException: Read failure --->
>> System.Net.Sockets.SocketException: Connection reset by peer
>>  at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32 offset,
>> Int32 size, SocketFlags flags) [0x000ad] in
>> /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/Socket.cs:1606
>>  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32
>> offset, Int32 size) [0x00067] in
>> /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:399
>>  --- End of inner exception stack trace ---
>>  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32
>> offset, Int32 size) [0x00078] in
>> /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:401
>>  at System.Net.RequestStream.Read (System.Byte[] buffer, Int32 offset,
>> Int32 count) [0x0003c] in
>> /usr/local/src/mono-2.11.1/mcs/class/System/System.Net/RequestStream.cs:142
>>  at System.IO.StreamReader.ReadBuffer () [0x00012] in
>> /usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:394
>>  at System.IO.StreamReader.Read (System.Char[] buffer, Int32 index, Int32
>> count) [0x00062] in
>> /usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:471
>>  at Mono.Xml2.XmlTextReader.ReadTextReader (Int32 remained) [0x0004f] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1256
>>  at Mono.Xml2.XmlTextReader.PeekChar () [0x00047] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1210
>>  at Mono.Xml2.XmlTextReader.ReadContent () [0x0003f] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1310
>>  at Mono.Xml2.XmlTextReader.Read () [0x00141] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:626
>>  at System.Xml.XmlTextReader.Read () [0x0006b] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader2.cs:564
>>  at System.Xml.XmlSimpleDictionaryReader.Read () [0x00000] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.Runtime.Serialization/System.Xml/XmlSimpleDictionaryReader.cs:253
>>  at System.Xml.XmlReader.MoveToContent () [0x00050] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlReader.cs:574
>>  at System.ServiceModel.Channels.XmlReaderMessage.ReadEnvelopeStart ()
>> [0x00000] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:146
>>  at System.ServiceModel.Channels.XmlReaderMessage..ctor
>> (System.ServiceModel.Channels.MessageVersion version,
>> System.Xml.XmlDictionaryReader reader, Int32 maxSizeOfHeaders) [0x00026] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:70
>>  at System.ServiceModel.Channels.Message.CreateMessage
>> (System.Xml.XmlDictionaryReader envelopeReader, Int32 maxSizeOfHeaders,
>> System.ServiceModel.Channels.MessageVersion version) [0x00022] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:427
>>  at System.ServiceModel.Channels.TextMessageEncoder.ReadMessage
>> (System.IO.Stream stream, Int32 maxSizeOfHeaders, System.String contentType)
>> [0x00011] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs:87
>>  at System.ServiceModel.Channels.Http.HttpReplyChannel.CreatePostMessage
>> (System.ServiceModel.Channels.Http.HttpContextInfo ctxi) [0x00081] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs:229
>>  at System.ServiceModel.Channels.Http.HttpReplyChannel.TryReceiveRequest
>> (TimeSpan timeout, System.ServiceModel.Channels.RequestContext& context)
>> [0x000aa] in
>> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs:172
>>  at
>> System.ServiceModel.Channels.ReplyChannelBase.<BeginTryReceiveRequest>m__10
>> (TimeSpan tout, System.ServiceModel.Channels.RequestContext& ctx) [0x0002f]
>> in
>> /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReplyChannelBase.cs:126
>>
>> I couldn't figure out how to check the connection status before trying to
>> ReadMessage or CreatePostMessage functions.
>>
>> Any Help ??
>>
>>
>> --
>> View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173.html
>> Sent from the Mono - Dev mailing list archive at Nabble.com.
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list <at> lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
shahbour | 27 Jun 2012 16:14
Picon

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Hello 

Thanks for the suggestion and updates.

I tested the application on windows machine (in fact i am using visual
studio to develop it) and the result was that if i close the browser while
running the console application under windows the application doesn't crash
but still raise an error where it should (ErrorHandler)

The below error is what i got and as you can see it what forward to
ErrorHandler class. 

2012-06-27 13:51:09,213 [3] ERROR (XXXXX\ErrorHandler.cs:19)
CDRServer.ErrorHandler
CDRServer.ErrorHandler.HandleError(XXXXX\ErrorHandler.cs:19) - An operation
was attempted on a nonexistent network connection
System.Net.HttpListenerException: An operation was attempted on a
nonexistent network connection
   at System.Net.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32
size)
   at System.ServiceModel.Channels.BytesReadPositionStream.Write(Byte[]
buffer,Int32 offset, Int32 count)
   at
System.ServiceModel.Channels.HttpOutput.ListenerResponseHttpOutput.ListenerResponseOutputStream.Write(Byte[]
buffer, Int32 offset, Int32 count)

while same thing if hosting it under mono in linux i got 

2012-06-27 14:19:08,755 [Threadpool worker] WARN 
CDRServer.WCFHost.bgwWCFHost_DoWork(:0) - WCF is still running with status
Opened
[0x44d7d940:] EXCEPTION handling: System.ObjectDisposedException: The object
was used after being disposed.
[0x44d7d940:] EXCEPTION handling: System.IO.IOException: EndRead failure
[0x43b74940:] EXCEPTION handling: System.Net.Sockets.SocketException: The
socket has been shut down
[0x43b74940:] EXCEPTION handling: System.IO.IOException: Write failure
Exception Write failure   at System.Net.Sockets.NetworkStream.Write
(System.Byte[] buffer, Int32 offset, Int32 size) [0x0008e] in
/usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:445 
  at System.Net.ResponseStream.InternalWrite (System.Byte[] buffer, Int32
offset, Int32 count) [0x00029] in
/usr/local/src/mono-2.11.1/mcs/class/System/System.Net/ResponseStream.cs:129 
  at System.Net.ResponseStream.Write (System.Byte[] buffer, Int32 offset,
Int32 count) [0x000dd] in
/usr/local/src/mono-2.11.1/mcs/class/System/System.Net/ResponseStream.cs:162 
  at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00157]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:160 
  at System.ServiceModel.Channels.Http.HttpRequestContext.Reply
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:101 
  at System.ServiceModel.Dispatcher.MessageProcessingContext.Reply (Boolean
useTimeout) [0x00026]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageProcessingContext.cs:96 
  at System.ServiceModel.Dispatcher.OperationInvokerHandler.Reply
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc, Boolean
useTimeout) [0x0001d]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationInvokerHandler.cs:69 
  at System.ServiceModel.Dispatcher.OperationInvokerHandler.ProcessRequest
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00044]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationInvokerHandler.cs:29 
  at
System.ServiceModel.Dispatcher.BaseRequestProcessorHandler.ProcessRequestChain
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessorHandler.cs:15 
  at
System.ServiceModel.Dispatcher.BaseRequestProcessorHandler.ProcessRequestChain
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00017]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessorHandler.cs:16 
  at System.ServiceModel.Dispatcher.HandlersChain.ProcessRequestChain
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x0000b]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessor.cs:72 
  at System.ServiceModel.Dispatcher.BaseRequestProcessor.ProcessRequest
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00018]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessor.cs:26 
2012-06-27 14:20:07,744 [Threadpool worker] ERROR
CDRServer.ErrorHandler.HandleError(:0) - Write failure
System.Net.Sockets.SocketException: The socket has been shut down
  at System.Net.Sockets.Socket.Send (System.Byte[] buf, Int32 offset, Int32
size, SocketFlags flags) [0x0008b] in
/usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/Socket.cs:1908 
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32
offset, Int32 size) [0x0006e] in
/usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:442 
[0x43b74940:] EXCEPTION handling: System.IO.IOException: Write failure
2012-06-27 14:20:07,747 [Threadpool worker] ERROR
CDRServer.ErrorHandler.HandleError(:0) - Write failure
System.Net.Sockets.SocketException: The socket has been shut down
  at System.Net.Sockets.Socket.Send (System.Byte[] buf, Int32 offset, Int32
size, SocketFlags flags) [0x0008b] in
/usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/Socket.cs:1908 
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32
offset, Int32 size) [0x0006e] in
/usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:442 
[0x43b74940:] EXCEPTION handling: System.ArgumentException: Value does not
fall within the expected range.

Unhandled Exception: System.ArgumentException: Value does not fall within
the expected range.
  at System.Xml.XmlWriter.WriteQualifiedNameInternal (System.String
localName, System.String ns) [0x000c9] in
/usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlWriter.cs:417 
  at System.Xml.XmlWriter.WriteQualifiedName (System.String localName,
System.String ns) [0x00000] in
/usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlWriter.cs:342 
  at System.Xml.XmlSimpleDictionaryWriter.WriteQualifiedName (System.String
localName, System.String ns) [0x00000]
in
/usr/local/src/mono-2.11.1/mcs/class/System.Runtime.Serialization/System.Xml/XmlSimpleDictionaryWriter.cs:144 
  at System.ServiceModel.Channels.MessageFault.WriteFaultCode
(System.Xml.XmlDictionaryWriter writer, System.ServiceModel.EnvelopeVersion
version, System.ServiceModel.FaultCode code, Boolean sub) [0x00058]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageFault.cs:431 
  at System.ServiceModel.Channels.MessageFault.WriteTo
(System.Xml.XmlDictionaryWriter writer, System.ServiceModel.EnvelopeVersion
version) [0x00011]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageFault.cs:417 
  at System.ServiceModel.Channels.MessageFaultBodyWriter.OnWriteBodyContents
(System.Xml.XmlDictionaryWriter writer) [0x00000]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageFaultBodyWriter.cs:57 
  at System.ServiceModel.Channels.BodyWriter.WriteBodyContents
(System.Xml.XmlDictionaryWriter writer) [0x00000]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BodyWriter.cs:57 
  at System.ServiceModel.Channels.SimpleMessage.OnWriteBodyContents
(System.Xml.XmlDictionaryWriter writer) [0x00000]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:331 
  at System.ServiceModel.Channels.Message.WriteBodyContents
(System.Xml.XmlDictionaryWriter writer) [0x00022]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:164 
  at System.ServiceModel.Channels.Message.WriteBody
(System.Xml.XmlDictionaryWriter writer) [0x0001c]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:149 
  at System.ServiceModel.Channels.Message.OnWriteMessage
(System.Xml.XmlDictionaryWriter writer) [0x00065]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:274 
  at System.ServiceModel.Channels.Message.WriteMessage
(System.Xml.XmlDictionaryWriter writer) [0x00026]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:176 
  at System.ServiceModel.Channels.Message.WriteMessage (System.Xml.XmlWriter
writer) [0x00000]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:181 
  at System.ServiceModel.Logger.LogMessage
(System.ServiceModel.Diagnostics.MessageLogTraceRecord log) [0x0008d] in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel/Logger.cs:191 
  at System.ServiceModel.Logger.LogMessage (MessageLogSourceKind sourceKind,
System.ServiceModel.Channels.Message& msg, Int64 maxMessageSize) [0x00029]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel/Logger.cs:171 
  at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00011]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:136 
  at System.ServiceModel.Channels.Http.HttpRequestContext.Reply
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:101 
  at System.ServiceModel.Channels.Http.HttpRequestContext.Reply
(System.ServiceModel.Channels.Message msg) [0x00000]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:96 
  at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest
(IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc)
[0x0003b]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:601 
  at
System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone
(IAsyncResult result) [0x0001a]
in
/usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:575 

The error change little depending if the host is replying or still getting
the request.

I think it is a bug , how to raise that ??

BR
Shahbour

--
View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173p4650199.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
Rob Wilkens | 27 Jun 2012 14:52
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

By the way, I noticed the bottom of the stack was similar to this earlier error message we corrected:
http://mono.1490590.n4.nabble.com/Exception-at-System-ServiceModel-Channels-Http-HttpReplyChannel-TryReceiveRequest-td4649878.html

I personally believe something called "*Try*ReceiveRequest" should be more fault tolerant, and allow failure, and in the case of failure at least with SocketException, fail out peacefully without causing issues in the whole program.  I think around there is where we should be looking to fix this.

I agree, Please do file a bug report, so at least it can be looked at, and include the stack trace.  IF you could provide a small sample of code in the bug report that can reproduce this it would be helpful, one way to do this might be to start transmission in one thread and intentionally crash (throw an unhandled exception) in another thread on the client.  Or at least mention that something like this might work.

And if you didn't submit a patch on your previous report (linked above) please describe exactly the lines you changed for that fix (copy and paste the lines) and someone will probably do the patch for you.

My network connection is down as i write this e-mail but i believe you can find the bug report feature by going to mono-project.com then get over to contributing then i think the bug reporting link is there.  Bug reports on the mailing list, i believe, have a tendency to get lost unless they are constantly talked about until they are fixed.

On 06/26/2012 08:49 AM, shahbour wrote:
Hello I got an WCF service that is running except at some time if the client send a request then close his program directly , ending the session the WCF console application crashes with below error [0x7f0b42f55700:] EXCEPTION handling: System.Net.Sockets.SocketException: Connection reset by peer [0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure [0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure Unhandled Exception: System.IO.IOException: Read failure ---> System.Net.Sockets.SocketException: Connection reset by peer at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32 offset, Int32 size, SocketFlags flags) [0x000ad] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/Socket.cs:1606 at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00067] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:399 --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00078] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:401 at System.Net.RequestStream.Read (System.Byte[] buffer, Int32 offset, Int32 count) [0x0003c] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net/RequestStream.cs:142 at System.IO.StreamReader.ReadBuffer () [0x00012] in /usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:394 at System.IO.StreamReader.Read (System.Char[] buffer, Int32 index, Int32 count) [0x00062] in /usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:471 at Mono.Xml2.XmlTextReader.ReadTextReader (Int32 remained) [0x0004f] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1256 at Mono.Xml2.XmlTextReader.PeekChar () [0x00047] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1210 at Mono.Xml2.XmlTextReader.ReadContent () [0x0003f] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1310 at Mono.Xml2.XmlTextReader.Read () [0x00141] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:626 at System.Xml.XmlTextReader.Read () [0x0006b] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader2.cs:564 at System.Xml.XmlSimpleDictionaryReader.Read () [0x00000] in /usr/local/src/mono-2.11.1/mcs/class/System.Runtime.Serialization/System.Xml/XmlSimpleDictionaryReader.cs:253 at System.Xml.XmlReader.MoveToContent () [0x00050] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlReader.cs:574 at System.ServiceModel.Channels.XmlReaderMessage.ReadEnvelopeStart () [0x00000] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:146 at System.ServiceModel.Channels.XmlReaderMessage..ctor (System.ServiceModel.Channels.MessageVersion version, System.Xml.XmlDictionaryReader reader, Int32 maxSizeOfHeaders) [0x00026] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:70 at System.ServiceModel.Channels.Message.CreateMessage (System.Xml.XmlDictionaryReader envelopeReader, Int32 maxSizeOfHeaders, System.ServiceModel.Channels.MessageVersion version) [0x00022] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:427 at System.ServiceModel.Channels.TextMessageEncoder.ReadMessage (System.IO.Stream stream, Int32 maxSizeOfHeaders, System.String contentType) [0x00011] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs:87 at System.ServiceModel.Channels.Http.HttpReplyChannel.CreatePostMessage (System.ServiceModel.Channels.Http.HttpContextInfo ctxi) [0x00081] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs:229 at System.ServiceModel.Channels.Http.HttpReplyChannel.TryReceiveRequest (TimeSpan timeout, System.ServiceModel.Channels.RequestContext& context) [0x000aa] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs:172 at System.ServiceModel.Channels.ReplyChannelBase.<BeginTryReceiveRequest>m__10 (TimeSpan tout, System.ServiceModel.Channels.RequestContext& ctx) [0x0002f] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReplyChannelBase.cs:126 I couldn't figure out how to check the connection status before trying to ReadMessage or CreatePostMessage functions. Any Help ?? -- View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173.html Sent from the Mono - Dev mailing list archive at Nabble.com. _______________________________________________ Mono-devel-list mailing list Mono-devel-list <at> lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list


_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
Rob Wilkens | 27 Jun 2012 15:16
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer


I sent a suggested fix, untested, under another thread, titled "BeginTryReceiveRequest and Socket error handling?".  I'm more wondering if it's a good idea or not, but it looks like it is safe to me in this case because we're in our own thread starting there.

The Exception being raised is appropriate, but the handling of it in BeginTryReceiveRequest is more of an issue, I believe.

-Rob

On 06/27/2012 08:52 AM, Rob Wilkens wrote:
By the way, I noticed the bottom of the stack was similar to this earlier error message we corrected:
http://mono.1490590.n4.nabble.com/Exception-at-System-ServiceModel-Channels-Http-HttpReplyChannel-TryReceiveRequest-td4649878.html

I personally believe something called "*Try*ReceiveRequest" should be more fault tolerant, and allow failure, and in the case of failure at least with SocketException, fail out peacefully without causing issues in the whole program.  I think around there is where we should be looking to fix this.

I agree, Please do file a bug report, so at least it can be looked at, and include the stack trace.  IF you could provide a small sample of code in the bug report that can reproduce this it would be helpful, one way to do this might be to start transmission in one thread and intentionally crash (throw an unhandled exception) in another thread on the client.  Or at least mention that something like this might work.

And if you didn't submit a patch on your previous report (linked above) please describe exactly the lines you changed for that fix (copy and paste the lines) and someone will probably do the patch for you.

My network connection is down as i write this e-mail but i believe you can find the bug report feature by going to mono-project.com then get over to contributing then i think the bug reporting link is there.  Bug reports on the mailing list, i believe, have a tendency to get lost unless they are constantly talked about until they are fixed.

On 06/26/2012 08:49 AM, shahbour wrote:
Hello I got an WCF service that is running except at some time if the client send a request then close his program directly , ending the session the WCF console application crashes with below error [0x7f0b42f55700:] EXCEPTION handling: System.Net.Sockets.SocketException: Connection reset by peer [0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure [0x7f0b42f55700:] EXCEPTION handling: System.IO.IOException: Read failure Unhandled Exception: System.IO.IOException: Read failure ---> System.Net.Sockets.SocketException: Connection reset by peer at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32 offset, Int32 size, SocketFlags flags) [0x000ad] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/Socket.cs:1606 at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00067] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:399 --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00078] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net.Sockets/NetworkStream.cs:401 at System.Net.RequestStream.Read (System.Byte[] buffer, Int32 offset, Int32 count) [0x0003c] in /usr/local/src/mono-2.11.1/mcs/class/System/System.Net/RequestStream.cs:142 at System.IO.StreamReader.ReadBuffer () [0x00012] in /usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:394 at System.IO.StreamReader.Read (System.Char[] buffer, Int32 index, Int32 count) [0x00062] in /usr/local/src/mono-2.11.1/mcs/class/corlib/System.IO/StreamReader.cs:471 at Mono.Xml2.XmlTextReader.ReadTextReader (Int32 remained) [0x0004f] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1256 at Mono.Xml2.XmlTextReader.PeekChar () [0x00047] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1210 at Mono.Xml2.XmlTextReader.ReadContent () [0x0003f] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:1310 at Mono.Xml2.XmlTextReader.Read () [0x00141] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader.cs:626 at System.Xml.XmlTextReader.Read () [0x0006b] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlTextReader2.cs:564 at System.Xml.XmlSimpleDictionaryReader.Read () [0x00000] in /usr/local/src/mono-2.11.1/mcs/class/System.Runtime.Serialization/System.Xml/XmlSimpleDictionaryReader.cs:253 at System.Xml.XmlReader.MoveToContent () [0x00050] in /usr/local/src/mono-2.11.1/mcs/class/System.XML/System.Xml/XmlReader.cs:574 at System.ServiceModel.Channels.XmlReaderMessage.ReadEnvelopeStart () [0x00000] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:146 at System.ServiceModel.Channels.XmlReaderMessage..ctor (System.ServiceModel.Channels.MessageVersion version, System.Xml.XmlDictionaryReader reader, Int32 maxSizeOfHeaders) [0x00026] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:70 at System.ServiceModel.Channels.Message.CreateMessage (System.Xml.XmlDictionaryReader envelopeReader, Int32 maxSizeOfHeaders, System.ServiceModel.Channels.MessageVersion version) [0x00022] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:427 at System.ServiceModel.Channels.TextMessageEncoder.ReadMessage (System.IO.Stream stream, Int32 maxSizeOfHeaders, System.String contentType) [0x00011] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs:87 at System.ServiceModel.Channels.Http.HttpReplyChannel.CreatePostMessage (System.ServiceModel.Channels.Http.HttpContextInfo ctxi) [0x00081] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs:229 at System.ServiceModel.Channels.Http.HttpReplyChannel.TryReceiveRequest (TimeSpan timeout, System.ServiceModel.Channels.RequestContext& context) [0x000aa] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs:172 at System.ServiceModel.Channels.ReplyChannelBase.<BeginTryReceiveRequest>m__10 (TimeSpan tout, System.ServiceModel.Channels.RequestContext& ctx) [0x0002f] in /usr/local/src/mono-2.11.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReplyChannelBase.cs:126 I couldn't figure out how to check the connection status before trying to ReadMessage or CreatePostMessage functions. Any Help ?? -- View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173.html Sent from the Mono - Dev mailing list archive at Nabble.com. _______________________________________________ Mono-devel-list mailing list Mono-devel-list <at> lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list




_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
shahbour | 27 Jun 2012 19:02
Picon

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Hello After more testing between Mac and Windows this is what i got Crash Windows Mac Linux Without ErroHandler No Yes Yes With ErrorHandler (return false ) No Yes Yes With ErrorHandler (return true) No No No Before i was always returning false in IErrorHandler implementation because i only implemented for logging purpose but when i return true for the HandleError , the application fire the error and log it but never crash. Now i trying to debug the application under MonoDevelop and repreduce the error, below is what i got

System.InvalidOperationException: Cannot be changed after headers are sent. at System.Net.HttpListenerResponse.set_ContentType (System.String value) [0x00027] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net/HttpListenerResponse.cs:107 at System.ServiceModel.Channels.Http.HttpStandaloneResponseInfo.set_ContentType (System.String value) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpContextInfo.cs:274 at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00046] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:140 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:101 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:96 at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest (IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc) [0x0003b] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:601 at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone (IAsyncResult result) [0x0001a] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:575
Reproducing the error is very simple, just host any application under console app and in any service function put Thread.Sleep(..) to give you time to close the browser before it reply. Then call this function from any client and close it before getting the response. In my live program i don't put Thread.sleep it is only to give us time between calling the function and closing the browser. Under windows we got the bellow that don't crash the application error.Message "An operation was attempted on a nonexistent network connection" error.InnerException {"An operation was attempted on a nonexistent network connection"} System.Exception {System.Net.HttpListenerException} error.ErrorCode 1229 BR Shahbour
View this message in context: Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer
Sent from the Mono - Dev mailing list archive at Nabble.com.
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
Rob Wilkens | 28 Jun 2012 02:35
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

This looks like an entirely different kind of error than we were seeing
before.  Here we are attempting, apparently, to change the content type
after we've already sent the headers, if the exception message is right,
and that sounds like a bug -- but i don't have the patience to dig
through the code right now to confirm that.  Tomorrow is a beach day for
me (my sister, the teacher, is home from school for the summer, so we've
got weekday group activities now).  Maybe tomorrow night if nothing is
going on i will try to look at it if no one else wants to.  I didn't
pick any bug reports to work on, so if i remember (no promises) to look
at this it will be at the top of my list.

Feel free to file a bug report about this -- earlier today from cell
phone i e-mailed you privately a link to the bug report feature.  It's
better than counting on me

-Rob

System.InvalidOperationException: Cannot be changed after headers are
sent. at System.Net.HttpListenerResponse.set_ContentType (System.String
value) [0x00027] in
/private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net/HttpListenerResponse.cs:107
at
System.ServiceModel.Channels.Http.HttpStandaloneResponseInfo.set_ContentType
(System.String value) [0x00000] in
/private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpContextInfo.cs:274
at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00046]
in
/private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:140
at System.ServiceModel.Channels.Http.HttpRequestContext.Reply
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000]
in
/private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:101
at System.ServiceModel.Channels.Http.HttpRequestContext.Reply
(System.ServiceModel.Channels.Message msg) [0x00000] in
/private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:96
at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest
(IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc)
[0x0003b] in
/private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:601
at
System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone
(IAsyncResult result) [0x0001a] in
/private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:575
Rob Wilkens | 28 Jun 2012 02:47
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

On 06/27/2012 01:02 PM, shahbour wrote:
Reproducing the error is very simple, just host any application under console app and in any service function put Thread.Sleep(..) to give you time to close the browser before it reply. Then call this function from any client and close it before getting the response. In my live program i don't put Thread.sleep it is only to give us time between calling the function and closing the browser. Under windows we got the bellow that don't crash the application error.Message "An operation was attempted on a nonexistent network connection" error.InnerException {"An operation was attempted on a nonexistent network connection"} System.Exception {System.Net.HttpListenerException} error.ErrorCode 1229 BR Shahbour

First, I'm glad you managed to get the error handler to prevent the application from crashing altogether by changing the return value.  I think i suggested that the other day or was that this morning, i don't remember now.

Next, I personally don't know what it means (above) when you say "just host any application under console app," or how to build a "service function", but that's my fault for never having used WCF.  Please understand, for example, just because someone knows how to code -- take for example -- an operating system, doesn't mean they know how to use every possible application that can run on the operating system (take, for example, some advanced math, science, or engineering program -- knowledge of low level C doesn't imply knowledge of advanced chemistry or physics for example).

-Rob
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
Rob Wilkens | 28 Jun 2012 13:55
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Re : The stacktrace below...

This occurs when an exception is raised in ChannelDispatcher.cs on line 601.  It tries to send back an exception message to the client here, i believe.  But when it does that, it uses the existing RequestContext. 

It's apparent that some data is apparently being sent, such as headers, on the RequestContext (rc) before we get to this exception.

If we're dealing with the case of SocketException, which caused us to fail mid-send on the RequestContext, perhaps, again, we shouldn't handle this like every other exception and not reply.  i.e. in the exception handler here, if exception is typeof(SocketException) don't reply, what might be more interesting, if this is reproducable, would be to - as debugging - print the exception message and/or stacktrace to the screen to see what exception caused this.

Did you file a bug report on this?  The discussion on this particular issue (or any particular bug) is probably better stored in the bug report comments than on the whole mailing list.  PLus comments like the above would stay in the bug report rather than get lost in the list.  IF you file a bug report, post a link to the bug report in this thread (the bug # should be enough).

-Rob


On 06/27/2012 01:02 PM, shahbour wrote:

Hello After more testing between Mac and Windows this is what i got Crash Windows Mac Linux Without ErroHandler No Yes Yes With ErrorHandler (return false ) No Yes Yes With ErrorHandler (return true) No No No Before i was always returning false in IErrorHandler implementation because i only implemented for logging purpose but when i return true for the HandleError , the application fire the error and log it but never crash. Now i trying to debug the application under MonoDevelop and repreduce the error, below is what i got

System.InvalidOperationException: Cannot be changed after headers are sent. at System.Net.HttpListenerResponse.set_ContentType (System.String value) [0x00027] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net/HttpListenerResponse.cs:107 at System.ServiceModel.Channels.Http.HttpStandaloneResponseInfo.set_ContentType (System.String value) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpContextInfo.cs:274 at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00046] in /private/tmp/monobuild/build/BUILD/mono-2.10.9

/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:140 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:101 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:96 at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest (IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc) [0x0003b] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:601 at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone (IAsyncResult result) [0x0001a] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:575
Reproducing the error is very simple, just host any application under console app and in any service function put Thread.Sleep(..) to give you time to close the browser before it reply. Then call this function from any client and close it before getting the response. In my live program i don't put Thread.sleep it is only to give us time between calling the function and closing the browser. Under windows we got the bellow that don't crash the application error.Message "An operation was attempted on a nonexistent network connection" error.InnerException {"An operation was attempted on a nonexistent network connection"} System.Exception :q
{System.Net.HttpListenerException} error.ErrorCode 1229 BR Shahbour
View this message in context: Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer
Sent from the Mono - Dev mailing list archive at Nabble.com.


_______________________________________________ Mono-devel-list mailing list Mono-devel-list <at> lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list


_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
Rob Wilkens | 28 Jun 2012 14:20
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer


Either of the attached patches illustrates what i was trying to say in that last patch

(1) attempt2.patch  : This attempts to patch just the below concern, and is based on a guess.
-or- (not both)
(2) combined.patch : This combines attempt2.patch with the patch i sent last night since they were on the same branch.

I'm not able to test these anything beyond "does it compile" because i don't have sample code to reproduce this with.

-Rob

On 06/28/2012 07:55 AM, Rob Wilkens wrote:
Re : The stacktrace below...

This occurs when an exception is raised in ChannelDispatcher.cs on line 601.  It tries to send back an exception message to the client here, i believe.  But when it does that, it uses the existing RequestContext. 

It's apparent that some data is apparently being sent, such as headers, on the RequestContext (rc) before we get to this exception.

If we're dealing with the case of SocketException, which caused us to fail mid-send on the RequestContext, perhaps, again, we shouldn't handle this like every other exception and not reply.  i.e. in the exception handler here, if exception is typeof(SocketException) don't reply, what might be more interesting, if this is reproducable, would be to - as debugging - print the exception message and/or stacktrace to the screen to see what exception caused this.

Did you file a bug report on this?  The discussion on this particular issue (or any particular bug) is probably better stored in the bug report comments than on the whole mailing list.  PLus comments like the above would stay in the bug report rather than get lost in the list.  IF you file a bug report, post a link to the bug report in this thread (the bug # should be enough).

-Rob


On 06/27/2012 01:02 PM, shahbour wrote:

Hello After more testing between Mac and Windows this is what i got Crash Windows Mac Linux Without ErroHandler No Yes Yes With ErrorHandler (return false ) No Yes Yes With ErrorHandler (return true) No No No Before i was always returning false in IErrorHandler implementation because i only implemented for logging purpose but when i return true for the HandleError , the application fire the error and log it but never crash. Now i trying to debug the application under MonoDevelop and repreduce the error, below is what i got

System.InvalidOperationException: Cannot be changed after headers are sent. at System.Net.HttpListenerResponse.set_ContentType (System.String value) [0x00027] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net/HttpListenerResponse.cs:107 at System.ServiceModel.Channels.Http.HttpStandaloneResponseInfo.set_ContentType (System.String value) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpContextInfo.cs:274 at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00046] in /private/tmp/monobuild/build/BUILD/mono-2.10.9

/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:140 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:101 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:96 at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest (IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc) [0x0003b] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:601 at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone (IAsyncResult result) [0x0001a] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:575
Reproducing the error is very simple, just host any application under console app and in any service function put Thread.Sleep(..) to give you time to close the browser before it reply. Then call this function from any client and close it before getting the response. In my live program i don't put Thread.sleep it is only to give us time between calling the function and closing the browser. Under windows we got the bellow that don't crash the application error.Message "An operation was attempted on a nonexistent network connection" error.InnerException {"An operation was attempted on a nonexistent network connection"} System.Exception :q
{System.Net.HttpListenerException} error.ErrorCode 1229 BR Shahbour
View this message in context: Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer
Sent from the Mono - Dev mailing list archive at Nabble.com.


_______________________________________________ Mono-devel-list mailing list Mono-devel-list <at> lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list




Attachment (attempt2.patch): text/x-patch, 931 bytes
Attachment (combined.patch): text/x-patch, 2119 bytes
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
Rob Wilkens | 28 Jun 2012 14:38
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Worth noting, with Combined patch applied (or both other applied separately), zero unit tests are failing.  So apparently, it doesn't make anything worse, at least as far as tests go.

-Rob

On 06/28/2012 08:20 AM, Rob Wilkens wrote:

Either of the attached patches illustrates what i was trying to say in that last patch

(1) attempt2.patch  : This attempts to patch just the below concern, and is based on a guess.
-or- (not both)
(2) combined.patch : This combines attempt2.patch with the patch i sent last night since they were on the same branch.

I'm not able to test these anything beyond "does it compile" because i don't have sample code to reproduce this with.

-Rob

On 06/28/2012 07:55 AM, Rob Wilkens wrote:
Re : The stacktrace below...

This occurs when an exception is raised in ChannelDispatcher.cs on line 601.  It tries to send back an exception message to the client here, i believe.  But when it does that, it uses the existing RequestContext. 

It's apparent that some data is apparently being sent, such as headers, on the RequestContext (rc) before we get to this exception.

If we're dealing with the case of SocketException, which caused us to fail mid-send on the RequestContext, perhaps, again, we shouldn't handle this like every other exception and not reply.  i.e. in the exception handler here, if exception is typeof(SocketException) don't reply, what might be more interesting, if this is reproducable, would be to - as debugging - print the exception message and/or stacktrace to the screen to see what exception caused this.

Did you file a bug report on this?  The discussion on this particular issue (or any particular bug) is probably better stored in the bug report comments than on the whole mailing list.  PLus comments like the above would stay in the bug report rather than get lost in the list.  IF you file a bug report, post a link to the bug report in this thread (the bug # should be enough).

-Rob


On 06/27/2012 01:02 PM, shahbour wrote:

Hello After more testing between Mac and Windows this is what i got Crash Windows Mac Linux Without ErroHandler No Yes Yes With ErrorHandler (return false ) No Yes Yes With ErrorHandler (return true) No No No Before i was always returning false in IErrorHandler implementation because i only implemented for logging purpose but when i return true for the HandleError , the application fire the error and log it but never crash. Now i trying to debug the application under MonoDevelop and repreduce the error, below is what i got

System.InvalidOperationException: Cannot be changed after headers are sent. at System.Net.HttpListenerResponse.set_ContentType (System.String value) [0x00027] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net/HttpListenerResponse.cs:107 at System.ServiceModel.Channels.Http.HttpStandaloneResponseInfo.set_ContentType (System.String value) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpContextInfo.cs:274 at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00046] in /private/tmp/monobuild/build/BUILD/mono-2.10.9

/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:140 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:101 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:96 at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest (IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc) [0x0003b] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:601 at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone (IAsyncResult result) [0x0001a] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:575
Reproducing the error is very simple, just host any application under console app and in any service function put Thread.Sleep(..) to give you time to close the browser before it reply. Then call this function from any client and close it before getting the response. In my live program i don't put Thread.sleep it is only to give us time between calling the function and closing the browser. Under windows we got the bellow that don't crash the application error.Message "An operation was attempted on a nonexistent network connection" error.InnerException {"An operation was attempted on a nonexistent network connection"} System.Exception :q
{System.Net.HttpListenerException} error.ErrorCode 1229 BR Shahbour
View this message in context: Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer
Sent from the Mono - Dev mailing list archive at Nabble.com.


_______________________________________________ Mono-devel-list mailing list Mono-devel-list <at> lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list






_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
Rob Wilkens | 28 Jun 2012 14:39
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

I mean zero RELATED unit tests were failing (in System.ServiceModel)


On 06/28/2012 08:38 AM, Rob Wilkens wrote:
Worth noting, with Combined patch applied (or both other applied separately), zero unit tests are failing.  So apparently, it doesn't make anything worse, at least as far as tests go.

-Rob

On 06/28/2012 08:20 AM, Rob Wilkens wrote:

Either of the attached patches illustrates what i was trying to say in that last patch

(1) attempt2.patch  : This attempts to patch just the below concern, and is based on a guess.
-or- (not both)
(2) combined.patch : This combines attempt2.patch with the patch i sent last night since they were on the same branch.

I'm not able to test these anything beyond "does it compile" because i don't have sample code to reproduce this with.

-Rob


On 06/28/2012 07:55 AM, Rob Wilkens wrote:
Re : The stacktrace below...

This occurs when an exception is raised in ChannelDispatcher.cs on line 601.  It tries to send back an exception message to the client here, i believe.  But when it does that, it uses the existing RequestContext. 

It's apparent that some data is apparently being sent, such as headers, on the RequestContext (rc) before we get to this exception.

If we're dealing with the case of SocketException, which caused us to fail mid-send on the RequestContext, perhaps, again, we shouldn't handle this like every other exception and not reply.  i.e. in the exception handler here, if exception is typeof(SocketException) don't reply, what might be more interesting, if this is reproducable, would be to - as debugging - print the exception message and/or stacktrace to the screen to see what exception caused this.

Did you file a bug report on this?  The discussion on this particular issue (or any particular bug) is probably better stored in the bug report comments than on the whole mailing list.  PLus comments like the above would stay in the bug report rather than get lost in the list.  IF you file a bug report, post a link to the bug report in this thread (the bug # should be enough).

-Rob


On 06/27/2012 01:02 PM, shahbour wrote:

Hello After more testing between Mac and Windows this is what i got Crash Windows Mac Linux Without ErroHandler No Yes Yes With ErrorHandler (return false ) No Yes Yes With ErrorHandler (return true) No No No Before i was always returning false in IErrorHandler implementation because i only implemented for logging purpose but when i return true for the HandleError , the application fire the error and log it but never crash. Now i trying to debug the application under MonoDevelop and repreduce the error, below is what i got

System.InvalidOperationException: Cannot be changed after headers are sent. at System.Net.HttpListenerResponse.set_ContentType (System.String value) [0x00027] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net/HttpListenerResponse.cs:107 at System.ServiceModel.Channels.Http.HttpStandaloneResponseInfo.set_ContentType (System.String value) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpContextInfo.cs:274 at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00046] in /private/tmp/monobuild/build/BUILD/mono-2.10.9

/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:140 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:101 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:96 at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest (IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc) [0x0003b] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:601 at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone (IAsyncResult result) [0x0001a] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:575
Reproducing the error is very simple, just host any application under console app and in any service function put Thread.Sleep(..) to give you time to close the browser before it reply. Then call this function from any client and close it before getting the response. In my live program i don't put Thread.sleep it is only to give us time between calling the function and closing the browser. Under windows we got the bellow that don't crash the application error.Message "An operation was attempted on a nonexistent network connection" error.InnerException {"An operation was attempted on a nonexistent network connection"} System.Exception :q
{System.Net.HttpListenerException} error.ErrorCode 1229 BR Shahbour
View this message in context: Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer
Sent from the Mono - Dev mailing list archive at Nabble.com.


_______________________________________________ Mono-devel-list mailing list Mono-devel-list <at> lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list









_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
shahbour | 29 Jun 2012 00:35
Picon

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

http://mono.1490590.n4.nabble.com/file/n4650235/TestWCFServer.zip
TestWCFServer.zip 

Hello Rob

I am attaching a simple application to demonstrate the error we are getting.

Unfortunately using the above example the server is not crashing but still
it raise the error (note that in my live app , some time it do the same but
crash more) 

If you run the server like below you will notice the error

mono --debug --trace=N:nothing TestWCFServer.exe
Press enter to exit
[0xb0a7d000:] EXCEPTION handling: System.Net.Sockets.SocketException:
Connection reset by peer
[0xb0a7d000:] EXCEPTION handling: System.IO.IOException: EndRead failure

To run the example just start the server , then start the client and before
getting the result back from server close it (Ctrl+C) 

I put a delay in the server to demonstrate the request over internet and to
have time to close it. After you close it by small time the application will
raise the above error .

Tomorrow I will change the client to a silver light application to simulate
exactly my application because the server crash approximately every time I
close the browser before getting the result in my live example.

BR
Shahbour

--
View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173p4650235.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
Robert Wilkens | 29 Jun 2012 12:15
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Thanks - I'm on my mac now and trying to set up mono develop..  It appears to have an easier time with the alpha
version of mono, but then it said 'update available' and downloaded an older version then stopped working
again, I'll get it soon.  Otherwise, I'll be on my linux laptop soon, just wanted to set up a second machine to
test on since networking code sometimes works better when it's not just localhost to localhost.

-Rob

On Jun 28, 2012, at 6:35 PM, shahbour wrote:

> http://mono.1490590.n4.nabble.com/file/n4650235/TestWCFServer.zip
> TestWCFServer.zip 
> 
> Hello Rob
> 
> I am attaching a simple application to demonstrate the error we are getting.
> 
> Unfortunately using the above example the server is not crashing but still
> it raise the error (note that in my live app , some time it do the same but
> crash more) 
> 
> If you run the server like below you will notice the error
> 
> mono --debug --trace=N:nothing TestWCFServer.exe
> Press enter to exit
> [0xb0a7d000:] EXCEPTION handling: System.Net.Sockets.SocketException:
> Connection reset by peer
> [0xb0a7d000:] EXCEPTION handling: System.IO.IOException: EndRead failure
> 
> To run the example just start the server , then start the client and before
> getting the result back from server close it (Ctrl+C) 
> 
> I put a delay in the server to demonstrate the request over internet and to
> have time to close it. After you close it by small time the application will
> raise the above error .
> 
> Tomorrow I will change the client to a silver light application to simulate
> exactly my application because the server crash approximately every time I
> close the browser before getting the result in my live example.
> 
> BR
> Shahbour
> 
> --
> View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173p4650235.html
> Sent from the Mono - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list <at> lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
Robert Wilkens | 9 Jul 2012 16:32
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Just want to update the list in case anyone was following…

I was able to reproduce some of the problems, and came up with some work arounds that wouldn't crash the WCF
server on client disconnect (windows doesn't crash the server), at least for the issues i was able to
reproduce.  I tried to keep the fixes confined so they have minimal impact on things which were unrelated,
for example, i catch the exceptions where they were causing failures, but where they were not causing
failures, in general i tried to let the exception flow through so it could be caught by something more
appropriate, such as the user program itself.

The person who reported them originally is going to try these changes on a live server over the next few days
to see if it helps matters.  They are in a pull request, but i am not in a hurry for them to be pulled, because
among other things, i don't generally use WCF and these issue don't affect me.  They were just interesting
to me.

I have personal issues (it's not me who is having the problem, but i need to deal with it), unrelated to mono,
which have been holding me up from trying to do more work with mono the last several days.  I don't want to get
into them here.  Depending on how things go, i might not touch mono source again until some time next month. 
Please don't take this as a lack of interest from me -- I've very much enjoyed being active here, both
learning and contributing (when i do it right).  Will try to keep up with the mailing list during this time,
and if a problem really interests me, i might find time to get involved.  

-Rob

On Jun 29, 2012, at 6:15 AM, Robert Wilkens wrote:

> Thanks - I'm on my mac now and trying to set up mono develop..  It appears to have an easier time with the alpha
version of mono, but then it said 'update available' and downloaded an older version then stopped working
again, I'll get it soon.  Otherwise, I'll be on my linux laptop soon, just wanted to set up a second machine to
test on since networking code sometimes works better when it's not just localhost to localhost.
> 
> -Rob
> 
> On Jun 28, 2012, at 6:35 PM, shahbour wrote:
> 
>> http://mono.1490590.n4.nabble.com/file/n4650235/TestWCFServer.zip
>> TestWCFServer.zip 
>> 
>> Hello Rob
>> 
>> I am attaching a simple application to demonstrate the error we are getting.
>> 
>> Unfortunately using the above example the server is not crashing but still
>> it raise the error (note that in my live app , some time it do the same but
>> crash more) 
>> 
>> If you run the server like below you will notice the error
>> 
>> mono --debug --trace=N:nothing TestWCFServer.exe
>> Press enter to exit
>> [0xb0a7d000:] EXCEPTION handling: System.Net.Sockets.SocketException:
>> Connection reset by peer
>> [0xb0a7d000:] EXCEPTION handling: System.IO.IOException: EndRead failure
>> 
>> To run the example just start the server , then start the client and before
>> getting the result back from server close it (Ctrl+C) 
>> 
>> I put a delay in the server to demonstrate the request over internet and to
>> have time to close it. After you close it by small time the application will
>> raise the above error .
>> 
>> Tomorrow I will change the client to a silver light application to simulate
>> exactly my application because the server crash approximately every time I
>> close the browser before getting the result in my live example.
>> 
>> BR
>> Shahbour
>> 
>> --
>> View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173p4650235.html
>> Sent from the Mono - Dev mailing list archive at Nabble.com.
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list <at> lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list <at> lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
Ali Shahbour | 11 Jul 2012 11:08
Picon

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Hello

Unfortunately the code still crashed with the below trace

[0x7ff24dc45700:] EXCEPTION handling: System.ObjectDisposedException: The
object was used after being disposed.
[0x7ff24dc45700:] EXCEPTION handling: System.IO.IOException: EndRead
failure
[0x7ff24de46700:] EXCEPTION handling: System.ObjectDisposedException: The
object was used after being disposed.
[0x7ff24de46700:] EXCEPTION handling: System.IO.IOException: Read failure
[0x7ff24de46700:] EXCEPTION handling: System.IO.IOException: Read failure

Unhandled Exception: System.IO.IOException: Read failure --->
System.ObjectDisposedException: The object was used after being disposed.
  at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32
offset, Int32 size, SocketFlags flags) [0x0007e] in
/usr/local/src/monorob/mono/mcs/class/System/System.Net.Sockets/Socket.cs:1
584
  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32
offset, Int32 size) [0x00067] in
/usr/local/src/monorob/mono/mcs/class/System/System.Net.Sockets/NetworkStre
am.cs:378
  --- End of inner exception stack trace ---
  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32
offset, Int32 size) [0x00078] in
/usr/local/src/monorob/mono/mcs/class/System/System.Net.Sockets/NetworkStre
am.cs:380
  at System.Net.RequestStream.Read (System.Byte[] buffer, Int32 offset,
Int32 count) [0x0003c] in
/usr/local/src/monorob/mono/mcs/class/System/System.Net/RequestStream.cs:14
1
  at System.IO.StreamReader.ReadBuffer () [0x00012] in
/usr/local/src/monorob/mono/mcs/class/corlib/System.IO/StreamReader.cs:394
  at System.IO.StreamReader.Read (System.Char[] buffer, Int32 index, Int32
count) [0x00062] in
/usr/local/src/monorob/mono/mcs/class/corlib/System.IO/StreamReader.cs:471
  at Mono.Xml2.XmlTextReader.ReadTextReader (Int32 remained) [0x0004f] in
/usr/local/src/monorob/mono/mcs/class/System.XML/System.Xml/XmlTextReader.c
s:1197
  at Mono.Xml2.XmlTextReader.PeekChar () [0x00047] in
/usr/local/src/monorob/mono/mcs/class/System.XML/System.Xml/XmlTextReader.c
s:1151
  at Mono.Xml2.XmlTextReader.ReadContent () [0x0003f] in
/usr/local/src/monorob/mono/mcs/class/System.XML/System.Xml/XmlTextReader.c
s:1251
  at Mono.Xml2.XmlTextReader.Read () [0x00141] in
/usr/local/src/monorob/mono/mcs/class/System.XML/System.Xml/XmlTextReader.c
s:577
  at System.Xml.XmlTextReader.Read () [0x0006b] in
/usr/local/src/monorob/mono/mcs/class/System.XML/System.Xml/XmlTextReader2.
cs:566
  at System.Xml.XmlSimpleDictionaryReader.Read () [0x00000] in
/usr/local/src/monorob/mono/mcs/class/System.Runtime.Serialization/System.X
ml/XmlSimpleDictionaryReader.cs:253
  at System.Xml.XmlReader.MoveToContent () [0x00050] in
/usr/local/src/monorob/mono/mcs/class/System.XML/System.Xml/XmlReader.cs:61
0
  at System.ServiceModel.Channels.XmlReaderMessage.ReadEnvelopeStart ()
[0x00000] in 
/usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
el.Channels/MessageImpl.cs:146
  at System.ServiceModel.Channels.XmlReaderMessage..ctor
(System.ServiceModel.Channels.MessageVersion version,
System.Xml.XmlDictionaryReader reader, Int32 maxSizeOfHeaders) [0x00026]
in 
/usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
el.Channels/MessageImpl.cs:70
  at System.ServiceModel.Channels.Message.CreateMessage
(System.Xml.XmlDictionaryReader envelopeReader, Int32 maxSizeOfHeaders,
System.ServiceModel.Channels.MessageVersion version) [0x00022] in
/usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
el.Channels/Message.cs:427
  at System.ServiceModel.Channels.TextMessageEncoder.ReadMessage
(System.IO.Stream stream, Int32 maxSizeOfHeaders, System.String
contentType) [0x00011] in
/usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
el.Channels/TextMessageEncoder.cs:87
  at System.ServiceModel.Channels.Http.HttpReplyChannel.CreatePostMessage
(System.ServiceModel.Channels.Http.HttpContextInfo ctxi) [0x0009e] in
/usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
el.Channels.Http/HttpReplyChannel.cs:229
  at System.ServiceModel.Channels.Http.HttpReplyChannel.TryReceiveRequest
(TimeSpan timeout, System.ServiceModel.Channels.RequestContext& context)
[0x000aa] in 
/usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
el.Channels.Http/HttpReplyChannel.cs:172
  at 
System.ServiceModel.Channels.ReplyChannelBase.<BeginTryReceiveRequest>m__10
 (TimeSpan tout, System.ServiceModel.Channels.RequestContext& ctx)
[0x0002f] in 
/usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
el.Channels/ReplyChannelBase.cs:128

I didn't have time yet to check it , but wanted to share it with you.

BR
Shabour

On 7/9/12 2:32 PM, "Robert Wilkens" <robwilkens <at> gmail.com> wrote:

>Just want to update the list in case anyone was followingŠ
>
>I was able to reproduce some of the problems, and came up with some work
>arounds that wouldn't crash the WCF server on client disconnect (windows
>doesn't crash the server), at least for the issues i was able to
>reproduce.  I tried to keep the fixes confined so they have minimal
>impact on things which were unrelated, for example, i catch the
>exceptions where they were causing failures, but where they were not
>causing failures, in general i tried to let the exception flow through so
>it could be caught by something more appropriate, such as the user
>program itself.
>
>The person who reported them originally is going to try these changes on
>a live server over the next few days to see if it helps matters.  They
>are in a pull request, but i am not in a hurry for them to be pulled,
>because among other things, i don't generally use WCF and these issue
>don't affect me.  They were just interesting to me.
>
>I have personal issues (it's not me who is having the problem, but i need
>to deal with it), unrelated to mono, which have been holding me up from
>trying to do more work with mono the last several days.  I don't want to
>get into them here.  Depending on how things go, i might not touch mono
>source again until some time next month.  Please don't take this as a
>lack of interest from me -- I've very much enjoyed being active here,
>both learning and contributing (when i do it right).  Will try to keep up
>with the mailing list during this time, and if a problem really interests
>me, i might find time to get involved.
>
>-Rob
>
>On Jun 29, 2012, at 6:15 AM, Robert Wilkens wrote:
>
>> Thanks - I'm on my mac now and trying to set up mono develop..  It
>>appears to have an easier time with the alpha version of mono, but then
>>it said 'update available' and downloaded an older version then stopped
>>working again, I'll get it soon.  Otherwise, I'll be on my linux laptop
>>soon, just wanted to set up a second machine to test on since networking
>>code sometimes works better when it's not just localhost to localhost.
>> 
>> -Rob
>> 
>> On Jun 28, 2012, at 6:35 PM, shahbour wrote:
>> 
>>> http://mono.1490590.n4.nabble.com/file/n4650235/TestWCFServer.zip
>>> TestWCFServer.zip
>>> 
>>> Hello Rob
>>> 
>>> I am attaching a simple application to demonstrate the error we are
>>>getting.
>>> 
>>> Unfortunately using the above example the server is not crashing but
>>>still
>>> it raise the error (note that in my live app , some time it do the
>>>same but
>>> crash more) 
>>> 
>>> If you run the server like below you will notice the error
>>> 
>>> mono --debug --trace=N:nothing TestWCFServer.exe
>>> Press enter to exit
>>> [0xb0a7d000:] EXCEPTION handling: System.Net.Sockets.SocketException:
>>> Connection reset by peer
>>> [0xb0a7d000:] EXCEPTION handling: System.IO.IOException: EndRead
>>>failure
>>> 
>>> To run the example just start the server , then start the client and
>>>before
>>> getting the result back from server close it (Ctrl+C)
>>> 
>>> I put a delay in the server to demonstrate the request over internet
>>>and to
>>> have time to close it. After you close it by small time the
>>>application will
>>> raise the above error .
>>> 
>>> Tomorrow I will change the client to a silver light application to
>>>simulate
>>> exactly my application because the server crash approximately every
>>>time I
>>> close the browser before getting the result in my live example.
>>> 
>>> BR
>>> Shahbour
>>> 
>>> --
>>> View this message in context:
>>>http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-Socke
>>>tException-Connection-reset-by-peer-tp4650173p4650235.html
>>> Sent from the Mono - Dev mailing list archive at Nabble.com.
>>> _______________________________________________
>>> Mono-devel-list mailing list
>>> Mono-devel-list <at> lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>> 
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list <at> lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>_______________________________________________
>Mono-devel-list mailing list
>Mono-devel-list <at> lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/mono-devel-list
Rob Wilkens | 11 Jul 2012 12:32
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer


This is a different problem, but it is related : It looks like i need to
handle IOException as well (in, at minimum, BeginTryReceiveRequest where
i was handling the other exceptions), i don't think that was in the
earlier stack traces, should be easy enough to catch and deal with. I'll
post in the bug report when i have that updated.

-Rob

On 07/11/2012 05:08 AM, Ali Shahbour wrote:
> Hello
>
> Unfortunately the code still crashed with the below trace
>
> [0x7ff24dc45700:] EXCEPTION handling: System.ObjectDisposedException: The
> object was used after being disposed.
> [0x7ff24dc45700:] EXCEPTION handling: System.IO.IOException: EndRead
> failure
> [0x7ff24de46700:] EXCEPTION handling: System.ObjectDisposedException: The
> object was used after being disposed.
> [0x7ff24de46700:] EXCEPTION handling: System.IO.IOException: Read failure
> [0x7ff24de46700:] EXCEPTION handling: System.IO.IOException: Read failure
>
> Unhandled Exception: System.IO.IOException: Read failure --->
> System.ObjectDisposedException: The object was used after being disposed.
>   at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32
> offset, Int32 size, SocketFlags flags) [0x0007e] in
> /usr/local/src/monorob/mono/mcs/class/System/System.Net.Sockets/Socket.cs:1
> 584
>   at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32
> offset, Int32 size) [0x00067] in
> /usr/local/src/monorob/mono/mcs/class/System/System.Net.Sockets/NetworkStre
> am.cs:378
>   --- End of inner exception stack trace ---
>   at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32
> offset, Int32 size) [0x00078] in
> /usr/local/src/monorob/mono/mcs/class/System/System.Net.Sockets/NetworkStre
> am.cs:380
>   at System.Net.RequestStream.Read (System.Byte[] buffer, Int32 offset,
> Int32 count) [0x0003c] in
> /usr/local/src/monorob/mono/mcs/class/System/System.Net/RequestStream.cs:14
> 1
>   at System.IO.StreamReader.ReadBuffer () [0x00012] in
> /usr/local/src/monorob/mono/mcs/class/corlib/System.IO/StreamReader.cs:394
>   at System.IO.StreamReader.Read (System.Char[] buffer, Int32 index, Int32
> count) [0x00062] in
> /usr/local/src/monorob/mono/mcs/class/corlib/System.IO/StreamReader.cs:471
>   at Mono.Xml2.XmlTextReader.ReadTextReader (Int32 remained) [0x0004f] in
> /usr/local/src/monorob/mono/mcs/class/System.XML/System.Xml/XmlTextReader.c
> s:1197
>   at Mono.Xml2.XmlTextReader.PeekChar () [0x00047] in
> /usr/local/src/monorob/mono/mcs/class/System.XML/System.Xml/XmlTextReader.c
> s:1151
>   at Mono.Xml2.XmlTextReader.ReadContent () [0x0003f] in
> /usr/local/src/monorob/mono/mcs/class/System.XML/System.Xml/XmlTextReader.c
> s:1251
>   at Mono.Xml2.XmlTextReader.Read () [0x00141] in
> /usr/local/src/monorob/mono/mcs/class/System.XML/System.Xml/XmlTextReader.c
> s:577
>   at System.Xml.XmlTextReader.Read () [0x0006b] in
> /usr/local/src/monorob/mono/mcs/class/System.XML/System.Xml/XmlTextReader2.
> cs:566
>   at System.Xml.XmlSimpleDictionaryReader.Read () [0x00000] in
> /usr/local/src/monorob/mono/mcs/class/System.Runtime.Serialization/System.X
> ml/XmlSimpleDictionaryReader.cs:253
>   at System.Xml.XmlReader.MoveToContent () [0x00050] in
> /usr/local/src/monorob/mono/mcs/class/System.XML/System.Xml/XmlReader.cs:61
> 0
>   at System.ServiceModel.Channels.XmlReaderMessage.ReadEnvelopeStart ()
> [0x00000] in 
> /usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
> el.Channels/MessageImpl.cs:146
>   at System.ServiceModel.Channels.XmlReaderMessage..ctor
> (System.ServiceModel.Channels.MessageVersion version,
> System.Xml.XmlDictionaryReader reader, Int32 maxSizeOfHeaders) [0x00026]
> in 
> /usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
> el.Channels/MessageImpl.cs:70
>   at System.ServiceModel.Channels.Message.CreateMessage
> (System.Xml.XmlDictionaryReader envelopeReader, Int32 maxSizeOfHeaders,
> System.ServiceModel.Channels.MessageVersion version) [0x00022] in
> /usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
> el.Channels/Message.cs:427
>   at System.ServiceModel.Channels.TextMessageEncoder.ReadMessage
> (System.IO.Stream stream, Int32 maxSizeOfHeaders, System.String
> contentType) [0x00011] in
> /usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
> el.Channels/TextMessageEncoder.cs:87
>   at System.ServiceModel.Channels.Http.HttpReplyChannel.CreatePostMessage
> (System.ServiceModel.Channels.Http.HttpContextInfo ctxi) [0x0009e] in
> /usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
> el.Channels.Http/HttpReplyChannel.cs:229
>   at System.ServiceModel.Channels.Http.HttpReplyChannel.TryReceiveRequest
> (TimeSpan timeout, System.ServiceModel.Channels.RequestContext& context)
> [0x000aa] in 
> /usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
> el.Channels.Http/HttpReplyChannel.cs:172
>   at 
> System.ServiceModel.Channels.ReplyChannelBase.<BeginTryReceiveRequest>m__10
>  (TimeSpan tout, System.ServiceModel.Channels.RequestContext& ctx)
> [0x0002f] in 
> /usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
> el.Channels/ReplyChannelBase.cs:128
>
>
> I didn't have time yet to check it , but wanted to share it with you.
>
> BR
> Shabour
>
>
>
>
>
> On 7/9/12 2:32 PM, "Robert Wilkens" <robwilkens <at> gmail.com> wrote:
>
>> Just want to update the list in case anyone was followingŠ
>>
>> I was able to reproduce some of the problems, and came up with some work
>> arounds that wouldn't crash the WCF server on client disconnect (windows
>> doesn't crash the server), at least for the issues i was able to
>> reproduce.  I tried to keep the fixes confined so they have minimal
>> impact on things which were unrelated, for example, i catch the
>> exceptions where they were causing failures, but where they were not
>> causing failures, in general i tried to let the exception flow through so
>> it could be caught by something more appropriate, such as the user
>> program itself.
>>
>> The person who reported them originally is going to try these changes on
>> a live server over the next few days to see if it helps matters.  They
>> are in a pull request, but i am not in a hurry for them to be pulled,
>> because among other things, i don't generally use WCF and these issue
>> don't affect me.  They were just interesting to me.
>>
>> I have personal issues (it's not me who is having the problem, but i need
>> to deal with it), unrelated to mono, which have been holding me up from
>> trying to do more work with mono the last several days.  I don't want to
>> get into them here.  Depending on how things go, i might not touch mono
>> source again until some time next month.  Please don't take this as a
>> lack of interest from me -- I've very much enjoyed being active here,
>> both learning and contributing (when i do it right).  Will try to keep up
>> with the mailing list during this time, and if a problem really interests
>> me, i might find time to get involved.
>>
>> -Rob
>>
>> On Jun 29, 2012, at 6:15 AM, Robert Wilkens wrote:
>>
>>> Thanks - I'm on my mac now and trying to set up mono develop..  It
>>> appears to have an easier time with the alpha version of mono, but then
>>> it said 'update available' and downloaded an older version then stopped
>>> working again, I'll get it soon.  Otherwise, I'll be on my linux laptop
>>> soon, just wanted to set up a second machine to test on since networking
>>> code sometimes works better when it's not just localhost to localhost.
>>>
>>> -Rob
>>>
>>> On Jun 28, 2012, at 6:35 PM, shahbour wrote:
>>>
>>>> http://mono.1490590.n4.nabble.com/file/n4650235/TestWCFServer.zip
>>>> TestWCFServer.zip
>>>>
>>>> Hello Rob
>>>>
>>>> I am attaching a simple application to demonstrate the error we are
>>>> getting.
>>>>
>>>> Unfortunately using the above example the server is not crashing but
>>>> still
>>>> it raise the error (note that in my live app , some time it do the
>>>> same but
>>>> crash more) 
>>>>
>>>> If you run the server like below you will notice the error
>>>>
>>>> mono --debug --trace=N:nothing TestWCFServer.exe
>>>> Press enter to exit
>>>> [0xb0a7d000:] EXCEPTION handling: System.Net.Sockets.SocketException:
>>>> Connection reset by peer
>>>> [0xb0a7d000:] EXCEPTION handling: System.IO.IOException: EndRead
>>>> failure
>>>>
>>>> To run the example just start the server , then start the client and
>>>> before
>>>> getting the result back from server close it (Ctrl+C)
>>>>
>>>> I put a delay in the server to demonstrate the request over internet
>>>> and to
>>>> have time to close it. After you close it by small time the
>>>> application will
>>>> raise the above error .
>>>>
>>>> Tomorrow I will change the client to a silver light application to
>>>> simulate
>>>> exactly my application because the server crash approximately every
>>>> time I
>>>> close the browser before getting the result in my live example.
>>>>
>>>> BR
>>>> Shahbour
>>>>
>>>> --
>>>> View this message in context:
>>>> http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-Socke
>>>> tException-Connection-reset-by-peer-tp4650173p4650235.html
>>>> Sent from the Mono - Dev mailing list archive at Nabble.com.
>>>> _______________________________________________
>>>> Mono-devel-list mailing list
>>>> Mono-devel-list <at> lists.ximian.com
>>>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>> _______________________________________________
>>> Mono-devel-list mailing list
>>> Mono-devel-list <at> lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list <at> lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
Rob Wilkens | 11 Jul 2012 13:03
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

On 07/11/2012 05:08 AM, Ali Shahbour wrote:
> Unhandled Exception: System.IO.IOException: Read failure --->
> System.ObjectDisposedException: The object was used after being disposed.
>   at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32
> offset, Int32 size, SocketFlags flags) [0x0007e] in
> /usr/local/src/monorob/mono/mcs/class/System/System.Net.Sockets/Socket.cs:1
> 584
....
> System.ServiceModel.Channels.ReplyChannelBase.<BeginTryReceiveRequest>m__10
>  (TimeSpan tout, System.ServiceModel.Channels.RequestContext& ctx)
> [0x0002f] in 
> /usr/local/src/monorob/mono/mcs/class/System.ServiceModel/System.ServiceMod
> el.Channels/ReplyChannelBase.cs:128
>
Sorry to pollute the list, but i wanted to share:
There were places, such in ReplyChannelBase, where i was handling
SocketException and XmlException but not IOException -- because i hadn't
seen a stacktrace where that happened.

And there were places elsewhere in that same patch, which i still
haven't seen a stacktrace for but can anticipate, where i handled
IOException and XmlException, but not SocketException.  Again, i have
yet to have seen a stacktrace where this occurred, but i can anticipate
it based on the above.

I fixed it in my source (not pushed/patched yet) so Wherever IOException
is handled, SocketException is also handled -- and wherever
SocketException is handled, IOException is also handled.

By handled, I mean 'clean fail' rather than crash.

-Rob
Rob Wilkens | 29 Jun 2012 13:08
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer


You mentioned you were working on your Mac.. Well I tested this, and on
Linux I couldn't reproduce it (mono verison 2.10.8.1 (Debian
2.10.8.1-1ubuntu2.1), and also the latest version including my fixes,
and it seemed not to happen either way). 

I spent a lot of time trying to reproduce it on Linux and it never
happened. 

The mac raised those exceptions, the Linux install did not (neither
crashed), but both continued to run as you described.

So, is this a mac specific issue to your knowledge?  Just curious. 

-Rob

On 06/28/2012 06:35 PM, shahbour wrote:
> http://mono.1490590.n4.nabble.com/file/n4650235/TestWCFServer.zip
> TestWCFServer.zip 
>
> Hello Rob
>
> I am attaching a simple application to demonstrate the error we are getting.
>
> Unfortunately using the above example the server is not crashing but still
> it raise the error (note that in my live app , some time it do the same but
> crash more) 
>
> If you run the server like below you will notice the error
>
> mono --debug --trace=N:nothing TestWCFServer.exe
> Press enter to exit
> [0xb0a7d000:] EXCEPTION handling: System.Net.Sockets.SocketException:
> Connection reset by peer
> [0xb0a7d000:] EXCEPTION handling: System.IO.IOException: EndRead failure
>
> To run the example just start the server , then start the client and before
> getting the result back from server close it (Ctrl+C) 
>
> I put a delay in the server to demonstrate the request over internet and to
> have time to close it. After you close it by small time the application will
> raise the above error .
>
> Tomorrow I will change the client to a silver light application to simulate
> exactly my application because the server crash approximately every time I
> close the browser before getting the result in my live example.
>
> BR
> Shahbour
>
> --
> View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173p4650235.html
> Sent from the Mono - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list <at> lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
Rob Wilkens | 29 Jun 2012 15:23
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Hi Shahbour,

I think this is a lucky timing issue..  That is: The Thread.Sleep makes
the SocketException happen in between when we are receiving or
sending...  In your stacktraces, it's always WHILE we are sending or
receiving that the disconnect happens and the crash occurs. 

One way to reproduce this might be to spawn copies that send LOTS of
data (could be a bunch of zeroes) and receives back a bunch of data
(again could be a bunch of zeroes), and while we spawn those copies,
wait just long enough for the connection to start, then kill the client
process externally (equivalent of kill -9 proc)....  And then just have
this whole spawn and kill thing in a loop until it fails.

One way to send lots of zeroes or whatever, would be to send a string,
but before we send that string, continually append to that string in a
loop so it becomes very long..

What do you think?

-Rob

On 06/28/2012 06:35 PM, shahbour wrote:
> http://mono.1490590.n4.nabble.com/file/n4650235/TestWCFServer.zip
> TestWCFServer.zip 
>
> Hello Rob
>
> I am attaching a simple application to demonstrate the error we are getting.
>
> Unfortunately using the above example the server is not crashing but still
> it raise the error (note that in my live app , some time it do the same but
> crash more) 
>
> If you run the server like below you will notice the error
>
> mono --debug --trace=N:nothing TestWCFServer.exe
> Press enter to exit
> [0xb0a7d000:] EXCEPTION handling: System.Net.Sockets.SocketException:
> Connection reset by peer
> [0xb0a7d000:] EXCEPTION handling: System.IO.IOException: EndRead failure
>
> To run the example just start the server , then start the client and before
> getting the result back from server close it (Ctrl+C) 
>
> I put a delay in the server to demonstrate the request over internet and to
> have time to close it. After you close it by small time the application will
> raise the above error .
>
> Tomorrow I will change the client to a silver light application to simulate
> exactly my application because the server crash approximately every time I
> close the browser before getting the result in my live example.
>
> BR
> Shahbour
>
> --
> View this message in context: http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-SocketException-Connection-reset-by-peer-tp4650173p4650235.html
> Sent from the Mono - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list <at> lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
Ali Shahbour | 29 Jun 2012 20:26
Picon

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

In my real application , I got a collection out of 300 000 record and I do
search on it and send the result or top 30 items. Also  I got a request
approximately every 5 second.

We can try this also

BR
Shabour

On 6/29/12 1:23 PM, "Rob Wilkens" <robwilkens <at> gmail.com> wrote:

>Hi Shahbour,
>
>I think this is a lucky timing issue..  That is: The Thread.Sleep makes
>the SocketException happen in between when we are receiving or
>sending...  In your stacktraces, it's always WHILE we are sending or
>receiving that the disconnect happens and the crash occurs.
>
>One way to reproduce this might be to spawn copies that send LOTS of
>data (could be a bunch of zeroes) and receives back a bunch of data
>(again could be a bunch of zeroes), and while we spawn those copies,
>wait just long enough for the connection to start, then kill the client
>process externally (equivalent of kill -9 proc)....  And then just have
>this whole spawn and kill thing in a loop until it fails.
>
>One way to send lots of zeroes or whatever, would be to send a string,
>but before we send that string, continually append to that string in a
>loop so it becomes very long..
>
>What do you think?
>
>-Rob
>
>On 06/28/2012 06:35 PM, shahbour wrote:
>> http://mono.1490590.n4.nabble.com/file/n4650235/TestWCFServer.zip
>> TestWCFServer.zip
>>
>> Hello Rob
>>
>> I am attaching a simple application to demonstrate the error we are
>>getting.
>>
>> Unfortunately using the above example the server is not crashing but
>>still
>> it raise the error (note that in my live app , some time it do the same
>>but
>> crash more) 
>>
>> If you run the server like below you will notice the error
>>
>> mono --debug --trace=N:nothing TestWCFServer.exe
>> Press enter to exit
>> [0xb0a7d000:] EXCEPTION handling: System.Net.Sockets.SocketException:
>> Connection reset by peer
>> [0xb0a7d000:] EXCEPTION handling: System.IO.IOException: EndRead failure
>>
>> To run the example just start the server , then start the client and
>>before
>> getting the result back from server close it (Ctrl+C)
>>
>> I put a delay in the server to demonstrate the request over internet
>>and to
>> have time to close it. After you close it by small time the application
>>will
>> raise the above error .
>>
>> Tomorrow I will change the client to a silver light application to
>>simulate
>> exactly my application because the server crash approximately every
>>time I
>> close the browser before getting the result in my live example.
>>
>> BR
>> Shahbour
>>
>> --
>> View this message in context:
>>http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-Socket
>>Exception-Connection-reset-by-peer-tp4650173p4650235.html
>> Sent from the Mono - Dev mailing list archive at Nabble.com.
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list <at> lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
>_______________________________________________
>Mono-devel-list mailing list
>Mono-devel-list <at> lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/mono-devel-list
Rob Wilkens | 29 Jun 2012 21:33
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Getting something that is consistently reproducible would be ideal.

I've got something else on front of my priority queue at the moment, and
may not get back to this right away.

- -Rob

On 06/29/2012 02:26 PM, Ali Shahbour wrote:
> In my real application , I got a collection out of 300 000 record and I do
> search on it and send the result or top 30 items. Also I got a request
> approximately every 5 second.
>
> We can try this also
>
> BR
> Shabour
>
>
>
> On 6/29/12 1:23 PM, "Rob Wilkens" <robwilkens <at> gmail.com> wrote:
>
>> Hi Shahbour,
>>
>> I think this is a lucky timing issue.. That is: The Thread.Sleep makes
>> the SocketException happen in between when we are receiving or
>> sending... In your stacktraces, it's always WHILE we are sending or
>> receiving that the disconnect happens and the crash occurs.
>>
>> One way to reproduce this might be to spawn copies that send LOTS of
>> data (could be a bunch of zeroes) and receives back a bunch of data
>> (again could be a bunch of zeroes), and while we spawn those copies,
>> wait just long enough for the connection to start, then kill the client
>> process externally (equivalent of kill -9 proc).... And then just have
>> this whole spawn and kill thing in a loop until it fails.
>>
>> One way to send lots of zeroes or whatever, would be to send a string,
>> but before we send that string, continually append to that string in a
>> loop so it becomes very long..
>>
>> What do you think?
>>
>> -Rob
>>
>> On 06/28/2012 06:35 PM, shahbour wrote:
>>> http://mono.1490590.n4.nabble.com/file/n4650235/TestWCFServer.zip
>>> TestWCFServer.zip
>>>
>>> Hello Rob
>>>
>>> I am attaching a simple application to demonstrate the error we are
>>> getting.
>>>
>>> Unfortunately using the above example the server is not crashing but
>>> still
>>> it raise the error (note that in my live app , some time it do the same
>>> but
>>> crash more)
>>>
>>> If you run the server like below you will notice the error
>>>
>>> mono --debug --trace=N:nothing TestWCFServer.exe
>>> Press enter to exit
>>> [0xb0a7d000:] EXCEPTION handling: System.Net.Sockets.SocketException:
>>> Connection reset by peer
>>> [0xb0a7d000:] EXCEPTION handling: System.IO.IOException: EndRead failure
>>>
>>> To run the example just start the server , then start the client and
>>> before
>>> getting the result back from server close it (Ctrl+C)
>>>
>>> I put a delay in the server to demonstrate the request over internet
>>> and to
>>> have time to close it. After you close it by small time the application
>>> will
>>> raise the above error .
>>>
>>> Tomorrow I will change the client to a silver light application to
>>> simulate
>>> exactly my application because the server crash approximately every
>>> time I
>>> close the browser before getting the result in my live example.
>>>
>>> BR
>>> Shahbour
>>>
>>> --
>>> View this message in context:
>>>
http://mono.1490590.n4.nabble.com/WCF-Fail-with-System-Net-Sockets-Socket
>>> Exception-Connection-reset-by-peer-tp4650173p4650235.html
>>> Sent from the Mono - Dev mailing list archive at Nabble.com.
>>> _______________________________________________
>>> Mono-devel-list mailing list
>>> Mono-devel-list <at> lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list <at> lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iF4EAREIAAYFAk/uAw4ACgkQcefeIla2m80pagD/VfovrNfU4IyB0P0i2ExarMOH
xfI+KsLTh3dKI2mJhkwA/jF+DqVbbKI2GiCTZbaluEgEZfTJksBe+LwdhM8zGnsJ
=xZUa
-----END PGP SIGNATURE-----
Rob Wilkens | 29 Jun 2012 16:17
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Oops, I mistakenly replied to just Shahbour.  Basically wanted to comment that we should move this discussion to a bug report i filed once i reproduced a crash:

https://bugzilla.xamarin.com/show_bug.cgi?id=5926

We're clogging up the mailing list with one issue too much when there are many issues that really deserve attention.

-Rob
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
shahbour | 28 Jun 2012 19:45
Picon

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Hello Rob

Sorry ,I was busy today and couldn't either fill a bug or test what we discussed, during this weekend I will build two small console applications , one server and one client that reproduce the below problem and post it as bug , this way you can see exactly what I am talking about and reproduce it under you environment .

Currently I don't have the framework source compiled under my mac (where I develop) so I need to start preparing the environment for my self to be able to edit the framework and test it fast.

BR
Shahbour

From: "Rob Wilkens [via Mono]" <[hidden email]>
Date: Thursday, June 28, 2012 5:38 PM
To: Ali Shahbour <[hidden email]>
Subject: Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Re : The stacktrace below...

This occurs when an exception is raised in ChannelDispatcher.cs on line 601.  It tries to send back an exception message to the client here, i believe.  But when it does that, it uses the existing RequestContext. 

It's apparent that some data is apparently being sent, such as headers, on the RequestContext (rc) before we get to this exception.

If we're dealing with the case of SocketException, which caused us to fail mid-send on the RequestContext, perhaps, again, we shouldn't handle this like every other exception and not reply.  i.e. in the exception handler here, if exception is typeof(SocketException) don't reply, what might be more interesting, if this is reproducable, would be to - as debugging - print the exception message and/or stacktrace to the screen to see what exception caused this.

Did you file a bug report on this?  The discussion on this particular issue (or any particular bug) is probably better stored in the bug report comments than on the whole mailing list.  PLus comments like the above would stay in the bug report rather than get lost in the list.  IF you file a bug report, post a link to the bug report in this thread (the bug # should be enough).

-Rob


On 06/27/2012 01:02 PM, shahbour wrote:

Hello After more testing between Mac and Windows this is what i got Crash Windows Mac Linux Without ErroHandler No Yes Yes With ErrorHandler (return false ) No Yes Yes With ErrorHandler (return true) No No No Before i was always returning false in IErrorHandler implementation because i only implemented for logging purpose but when i return true for the HandleError , the application fire the error and log it but never crash. Now i trying to debug the application under MonoDevelop and repreduce the error, below is what i got

System.InvalidOperationException: Cannot be changed after headers are sent. at System.Net.HttpListenerResponse.set_ContentType (System.String value) [0x00027] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net/HttpListenerResponse.cs:107 at System.ServiceModel.Channels.Http.HttpStandaloneResponseInfo.set_ContentType (System.String value) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpContextInfo.cs:274 at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00046] in /private/tmp/monobuild/build/BUILD/mono-2.10.9

/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:140 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:101 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:96 at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest (IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc) [0x0003b] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:601 at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone (IAsyncResult result) [0x0001a] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:575
Reproducing the error is very simple, just host any application under console app and in any service function put Thread.Sleep(..) to give you time to close the browser before it reply. Then call this function from any client and close it before getting the response. In my live program i don't put Thread.sleep it is only to give us time between calling the function and closing the browser. Under windows we got the bellow that don't crash the application error.Message "An operation was attempted on a nonexistent network connection" error.InnerException {"An operation was attempted on a nonexistent network connection"} System.Exception :q
{System.Net.HttpListenerException} error.ErrorCode 1229 BR Shahbour
View this message in context: Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer
Sent from the Mono - Dev mailing list archive at Nabble.com.


_______________________________________________ Mono-devel-list mailing list [hidden email]http://lists.ximian.com/mailman/listinfo/mono-devel-list



_______________________________________________
Mono-devel-list mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/mono-devel-list


To unsubscribe from WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer, click here.
NAML

View this message in context: Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer
Sent from the Mono - Dev mailing list archive at Nabble.com.
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
Rob Wilkens | 29 Jun 2012 02:41
Picon
Gravatar

Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer


Thanks for being willing to write the sample code, I had started to read about WCF tonight, I'm familiar with the concepts (already was on most of them), but didn't yet get up to actual implementation (only got about 13 pages into the book when I received your message).  It's something i'll learn when i need to, and since you're writing the sample code, you're saving me (or whomever looks into it) some time, which makes it more likely it will be resolved for you in a reasonable amount of time.  Right now, this problem is interesting to me, so i'd like to look into it.  If I do look into it, I'll try to compare to Windows .NET behavior.

I'm going to remove the pull request until I have a chance to compare to .net behavior with actual code.

-Rob

On 06/28/2012 01:45 PM, shahbour wrote:
Hello Rob

Sorry ,I was busy today and couldn't either fill a bug or test what we discussed, during this weekend I will build two small console applications , one server and one client that reproduce the below problem and post it as bug , this way you can see exactly what I am talking about and reproduce it under you environment .

Currently I don't have the framework source compiled under my mac (where I develop) so I need to start preparing the environment for my self to be able to edit the framework and test it fast.

BR
Shahbour

From: "Rob Wilkens [via Mono]" <[hidden email]>
Date: Thursday, June 28, 2012 5:38 PM
To: Ali Shahbour <[hidden email]>
Subject: Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer

Re : The stacktrace below...

This occurs when an exception is raised in ChannelDispatcher.cs on line 601.  It tries to send back an exception message to the client here, i believe.  But when it does that, it uses the existing RequestContext. 

It's apparent that some data is apparently being sent, such as headers, on the RequestContext (rc) before we get to this exception.

If we're dealing with the case of SocketException, which caused us to fail mid-send on the RequestContext, perhaps, again, we shouldn't handle this like every other exception and not reply.  i.e. in the exception handler here, if exception is typeof(SocketException) don't reply, what might be more interesting, if this is reproducable, would be to - as debugging - print the exception message and/or stacktrace to the screen to see what exception caused this.

Did you file a bug report on this?  The discussion on this particular issue (or any particular bug) is probably better stored in the bug report comments than on the whole mailing list.  PLus comments like the above would stay in the bug report rather than get lost in the list.  IF you file a bug report, post a link to the bug report in this thread (the bug # should be enough).

-Rob


On 06/27/2012 01:02 PM, shahbour wrote:

Hello After more testing between Mac and Windows this is what i got Crash Windows Mac Linux Without ErroHandler No Yes Yes With ErrorHandler (return false ) No Yes Yes With ErrorHandler (return true) No No No Before i was always returning false in IErrorHandler implementation because i only implemented for logging purpose but when i return true for the HandleError , the application fire the error and log it but never crash. Now i trying to debug the application under MonoDevelop and repreduce the error, below is what i got

System.InvalidOperationException: Cannot be changed after headers are sent. at System.Net.HttpListenerResponse.set_ContentType (System.String value) [0x00027] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net/HttpListenerResponse.cs:107 at System.ServiceModel.Channels.Http.HttpStandaloneResponseInfo.set_ContentType (System.String value) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpContextInfo.cs:274 at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00046] in /private/tmp/monobuild/build/BUILD/mono-2.10.9

/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:140 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:101 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpRequestContext.cs:96 at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest (IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc) [0x0003b] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:601 at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone (IAsyncResult result) [0x0001a] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:575
Reproducing the error is very simple, just host any application under console app and in any service function put Thread.Sleep(..) to give you time to close the browser before it reply. Then call this function from any client and close it before getting the response. In my live program i don't put Thread.sleep it is only to give us time between calling the function and closing the browser. Under windows we got the bellow that don't crash the application error.Message "An operation was attempted on a nonexistent network connection" error.InnerException {"An operation was attempted on a nonexistent network connection"} System.Exception :q
{System.Net.HttpListenerException} error.ErrorCode 1229 BR Shahbour
View this message in context: Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer
Sent from the Mono - Dev mailing list archive at Nabble.com.


_______________________________________________ Mono-devel-list mailing list [hidden email]http://lists.ximian.com/mailman/listinfo/mono-devel-list



_______________________________________________
Mono-devel-list mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/mono-devel-list


To unsubscribe from WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer, click here.
NAML

View this message in context: Re: WCF Fail with System.Net.Sockets.SocketException: Connection reset by peer
Sent from the Mono - Dev mailing list archive at Nabble.com.


_______________________________________________ Mono-devel-list mailing list Mono-devel-list <at> lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list


_______________________________________________
Mono-devel-list mailing list
Mono-devel-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Gmane