How to prevent socket writing exception ?

Support questions for server and client (Windows, iPhone, Android, Linux)
Post Reply
Isachris83
1 star
1 star
Posts: 9
Joined: Sun 20 May 2012, 11:49

How to prevent socket writing exception ?

Post by Isachris83 » Wed 20 Aug 2014, 21:11

Hi,

I'm using Sk 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 the sk server ?)

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

Martin
Administrator
Administrator
Posts: 2655
Joined: Tue 09 Nov 2010, 20:25

Re: How to prevent socket writing exception ?

Post by Martin » Thu 21 Aug 2014, 15:21

When searching for this error, it seems to be a recognized bug but I am not sure whether it has been fixed in later versions of Mono or not.
It is surfacing on Mono when a client disconnects prematurely. This is related to the WCF (Windows Communication Foundation) in Mono, which we are moving away from, but as of now the best bet would be to update the Mono version to check whether it is fixed in RPi as well (since it is fixed on other platforms).
Martin | Switch King

Isachris83
1 star
1 star
Posts: 9
Joined: Sun 20 May 2012, 11:49

Re: How to prevent socket writing exception ?

Post by Isachris83 » Thu 21 Aug 2014, 21:09

I have installed Mono-complete one week ago (3.2.8 version) and the bug is not solved.
Meanwhile, I have found a workaround to avoid the crash. After using sk on iphone, instead of letting the iphone to turn off automatically with a running sk application, i just push the home button to come back on the start panel (those with all the icons) and that works fine ! No socket write error.
Finally, it's not a big problem when you understand it....

Best regards,

Christophe.

Martin
Administrator
Administrator
Posts: 2655
Joined: Tue 09 Nov 2010, 20:25

Re: How to prevent socket writing exception ?

Post by Martin » Mon 25 Aug 2014, 19:38

Not big, but extremely annoying.
Thanks for the tip, though!
Martin | Switch King

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests