[Mono-list] How to prevent socket writing exception ?

Christophe Maréchal isachris83 at gmail.com
Sun Sep 14 20:07:31 UTC 2014


Hi,

I'm using SwitcKing on Rpi with Mono and everything is ok except with 
the iphone client.
I encounter socket write exception at some times (when the iphone turns 
off while i am using sk) and that causes a crash of the server (see below)
I have understood the problem (abort from the client that causes write 
failure from the server on the socket) but i can't solve it ? ( it is 
solvable or it is a bug of Mono ?)

Any idea ?

Mono version: 3.2.8 (Debian 3.2.8+dfsg-4+rpi1)
Switch King version: 3.2.1.0 (Build date 23/01/2013 21:01:16)

the error message following the server's crash :

Exception Write failure at System.Net.Sockets.NetworkStream.Write 
(System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename 
unknown>:0
at System.Net.ResponseStream.InternalWrite (System.Byte[] buffer, Int32 
offset, Int32 count) [0x00000] in <filename unknown>:0
at System.Net.ResponseStream.Write (System.Byte[] buffer, Int32 offset, 
Int32 count) [0x00000] in <filename unknown>:0
at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply 
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] 
in <filename
at System.ServiceModel.Channels.Http.HttpRequestContext.Reply 
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] 
in <filename unknown>
at System.ServiceModel.Dispatcher.MessageProcessingContext.Reply 
(Boolean useTimeout) [0x00000] in <filename unknown>:0
at System.ServiceModel.Dispatcher.OperationInvokerHandler.Reply 
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc, Boolean 
useTimeout) [0x00000
at System.ServiceModel.Dispatcher.OperationInvokerHandler.ProcessRequest 
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] 
in <filen
at 
System.ServiceModel.Dispatcher.BaseRequestProcessorHandler.ProcessRequestChain 
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000]
at 
System.ServiceModel.Dispatcher.BaseRequestProcessorHandler.ProcessRequestChain 
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000]
at System.ServiceModel.Dispatcher.HandlersChain.ProcessRequestChain 
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] 
in <filename u
at System.ServiceModel.Dispatcher.BaseRequestProcessor.ProcessRequest 
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] 
in <filename

Unhandled Exception:
System.InvalidOperationException: Cannot be changed after headers are sent.
at System.Net.HttpListenerResponse.set_ContentType (System.String value) 
[0x00000] in <filename unknown>:0
at 
System.ServiceModel.Channels.Http.HttpStandaloneResponseInfo.set_ContentType 
(System.String value) [0x00000] in <filename unknown>:0
at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply 
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] 
in <filename
at System.ServiceModel.Channels.Http.HttpRequestContext.Reply 
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] 
in <filename unknown>
at System.ServiceModel.Channels.Http.HttpRequestContext.Reply 
(System.ServiceModel.Channels.Message msg) [0x00000] in <filename unknown>:0
at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest 
(IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc) 
[0x00000] in <f
at 
System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone 
(IAsyncResult result) [0x00000] in <filename unknown>:0


Christophe Maréchal


More information about the Mono-list mailing list