Socket Exception on Remoting in Framework 2  
Author Message
Joseph Moraise





PostPosted: .NET Framework Networking and Communication, Socket Exception on Remoting in Framework 2 Top

Hi All,

I am getting an unexepected exception on remoting in Framework 2. The Context was , On Server side i have a singleton ton remote object, and the same is consumed by a .net client and i am calling the client exe multiple times from a batch file. The result is its raising an exception some time in the very begining , some time after few service invocation or some time very last. The Exception is some what weired...

System.IO.IOException occurred
Message="The read operation failed, see inner exception."
Source="System"

Inner Exception {"A non-blocking socket operation could not be completed immediately"}

Native Error Code - 10035

Socket Error Code - System.Net.Sockets.SocketError.WouldBlock
StackTrace:
Server stack trace:
at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.SocketHandler.BufferMoreData()
at System.Runtime.Remoting.Channels.SocketHandler.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.Tcp.TcpFixedLengthReadingStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.BinaryReader.ReadBytes(Int32 count)
at System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Read(__BinaryParser input)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadSerializationHeaderRecord()
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.UnsafeDeserialize(Stream serializationStream, HeaderHandler handler)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel)
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at shared.communication.interfaces.I_CSCOM.GetServerResponse(Transport Transport)
at client.serverio.proxy.RemotingProxy.GetServerResponse(Transport Transport)

Please see the code listing

Server


BinaryServerFormatterSinkProvider objBinaryServerFormatterSinkProvider = new BinaryServerFormatterSinkProvider();
objBinaryServerFormatterSinkProvider.TypeFilterLevel =TypeFilterLevel.Full;
m_objTcpServerChannel = new TcpServerChannel("MyServer",8080,objBinaryServerFormatterSinkProvider);

ChannelServices.RegisterChannel(m_objTcpServerChannel,true );
m_objTCPServer.RegisterInterface(typeof(ServiceBus),"MyServiceBus");
m_objTcpServerChannel.StartListening(null);

Client

m_objTcpClientChannel = new TcpClientChannel("", new BinaryClientFormatterSinkProvider());
ChannelServices.RegisterChannel(m_objTcpClientChannel,true );
I_XAL m_objXAL = (I_XAL) Activator.GetObject(InterfaceType,"tcp://localhost:8080/MyServiceBus");
objKPITemplateDefinition = (KPITemplateDefinition)XAL.SaveObject(objKPITemplateDefinition,"TestLoader",true);

The Other intresting fact is that the same is code is workign fine on Framework 1.1

If any body can direct me what wrong in this.

Thank you guys for your support to developers!!!

Cheers!!!



.NET Development18  
 
 
ranamauro





PostPosted: .NET Framework Networking and Communication, Socket Exception on Remoting in Framework 2 Top

Something down the line is putting your client socket in blocking mode, unfortunately I can't say what or why. What I can say, though, is that if you're happy with the way this was working in 1.1, you can change the followign call:
ChannelServices.RegisterChannel(m_objTcpServerChannel, true);
to
ChannelServices.RegisterChannel(m_objTcpServerChannel, false);
since I believe security over tcp is new in 2.0, this woudl be real way of getting the 1.1 behavior parity.



 
 
Joseph Moraise





PostPosted: .NET Framework Networking and Communication, Socket Exception on Remoting in Framework 2 Top

Hi ranamauro ,

Thanks for your reply. but even that will not solving the problem. its again raising socket exception..... I did n't understand why this is happening

System Error [[System] [A non-blocking socket operation could not be completed immediately] [
Server stack trace:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Runtime.Remoting.Channels.SocketStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.SocketHandler.BufferMoreData()
at System.Runtime.Remoting.Channels.SocketHandler.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.Tcp.TcpFixedLengthReadingStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.BinaryReader.ReadBytes(Int32 count)
at System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Read(__BinaryParser input)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadSerializationHeaderRecord()
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel)
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)

Exception rethrown at [0]:
at client.mvc.controller.ModelIO.Login(String UserName, String Password, String ProfileName, Functions Functions, Model Model, Boolean ReLogFlag)
at client.mvc.controller.Controller.Login(String UserName, String Password, String ProfileName, Boolean RelogFlag, SimpleLoginForm LoginForm)
at client.mvc.processes.LoginProcess.Login_Clicked(Object sender, EventArgs e)]]