Re: Events in .Net Remoting

Tech-Archive recommends: Fix windows errors by optimizing your registry



I have not followed all of your discussion very closely, but one thing struck me.
I only use 1 channel on both the client and the server. It handles both the remote calls and the events. I have not put this
code into production yet, so it has not been used a lot, but in my testing, I have never seen the error that you describe.

FYI.
I used the event mechanism described in Rammer's book (Advanced .NET Remoting) and have everything done via abstract classes
and/or interfaces so that my shared code dll consists of only a 600 lines of code (500 of which is in a non-application specific
base class) that only implements the 'framework' management and all the business logic is only on the server.

On 11 Jul 2005 23:54:32 -0700, vsapre80@xxxxxxxxx wrote:

>Hi,
>
>I am writing with respect to the Events in .Net Remoting that I had
>written about.
>
>My .Net Remoting application had started, but now it is working
>intermittently...sometimes it works, and sometimes it doesn't. I have
>not been able to exactly reproduce or pinpoint why I am getting errors.
>
>
>These days, the main error happens like this:
>
>I start the server process on the remote machine, it configures the
>remoting channel to be used. Then I start a client process on native
>machine. Then I register a channel to be used for remoting, and also
>another channel for the callbacks..both on client side. The second
>channel uses a different port than the first one, and also the client
>side config file specifies port:0 to be used for listening to
>callbacks.
>
>Then from the client, using the first channel, I request some strings
>from a remote object. This works fine, indicating that client-to-sever
>requests are being answered correctly.
>
>Then I force a method on the server end (through a GUI control on the
>server form) to raise an event, and send a call back to the client.
>Here I get an error which says: "The requested address is not valid in
>its context".
>
>The callback has been implemented using a delegate, defined in the
>remote object. Also a event handler base class is defined in the remote
>object, and the client side event handler derives from this base class.
>It implements the base class's virtual method. These methods (virtual
>and implemented) match the signature and return type of the delegate.
>
>I have not been able to find any specific documentation on this error
>files. This error turns out to be a general error in Windows Socket
>programming.
>
>Did you have this kind of an error?
>If yes, what did you do to get over it?
>
>Also, can you suggest me a place where I can look how exceptions/errors
>are handled by applications that work on .Net Remoting?
>
>Thanks in advance,
>It would be a great help if you could take time out to answer my
>questions.
>
>Regards,
>Vishal
>
>
>Christopher Schipper wrote:
>> This is what I have found.
>>
>> You are getting that error message because you basically need to setup a
>> remoting 'server' on the client for the server to communicate back to your
>> application... The server side is throwing that because there are no ports
>> open on your client.
>>
>> In the example below the port = 0 is critical as .net somehow knows to use
>> that as the same tcp connection created while connecting to the server. Hope
>> this helps I searched for days to find it.
>>
>>
>> ... Server...
>> Dim serverProv As BinaryServerFormatterSinkProvider = New
>> BinaryServerFormatterSinkProvider
>>
>> serverProv.TypeFilterLevel =
>> Runtime.Serialization.Formatters.TypeFilterLevel.Full
>>
>> Dim Props As IDictionary = New Hashtable
>>
>> Props("name") = "SERVER"
>>
>> Props("port") = 5000
>>
>> ChannelServices.RegisterChannel(New TcpServerChannel(Props, serverProv))
>>
>> RemotingServices.Marshal( ROUTINE , "CHAT")
>>
>> ...Client...
>>
>> Dim serverProv As BinaryServerFormatterSinkProvider = New
>> BinaryServerFormatterSinkProvider
>>
>> serverProv.TypeFilterLevel =
>> Runtime.Serialization.Formatters.TypeFilterLevel.Full
>>
>> Dim clientProv As BinaryClientFormatterSinkProvider = New
>> BinaryClientFormatterSinkProvider
>>
>> Dim Props As IDictionary = New Hashtable
>>
>> Props("name") = "CLIENT"
>>
>> Props("port") = 0
>>
>> ChannelServices.RegisterChannel(New TcpChannel(Props, clientProv,
>> serverProv))
>>
>> OBJECT= Activator.GetObject(GetType(ChatServer),
>> "tcp://localhost:5000/CHAT")
>>
>>
>>
>>
>> <vsapre80@xxxxxxxxx> wrote in message
>> news:1120610599.035206.252900@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> > Hi,
>> >
>> > I have read most of the mails that have been passed on this group about
>> > handling events in a remoting app, however my question seems to be
>> > different from them. Here's my question...
>> >
>> > I have a client-server application setup, which is working fine when
>> > the client needs some functionality from a remotable object available
>> > at the remote machine, and the server helps in getting the
>> > functionality.
>> >
>> > However, when I try to send an event (which I did based on this
>> > article: http://www.developer.com/net/cplus/article.php/3339611), I get
>> > an exception on the server side which says:
>> >
>> > System.Net.Sockets.SocketException: A connection attempt failed because
>> > the connected party did not properly System respond after a period of
>> > time, or established connection failed because connected host has
>> > failed to respond
>> >
>> > It seems as if the client application has died or something...however,
>> > the regular client side requests still work fine.
>> >
>> >
>> > Can anyone please help me here?
>> >
>> > Thanks and Best regards,
>> > Vishal
>> >
>> >
>> >
>> > Here's the Server Stack Trace
>> > Server stack trace:
>> > at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
>> > at
>> > System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket()
>> > at System.Runtime.Remoting.Channels.SocketCache.GetSocket(String
>> > machineAndPort)
>> > at
>> > System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.SendRequestWithRetry(IMessage
>> > msg, ITransportHeaders requestHeaders, Stream requestStream)
>> >
>> > at
>> > System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage
>> > msg, ITransportHeaders requestHeaders, Stream requestStream,
>> > ITransportHeaders& responseHeaders, Stream& responseStream)
>> >
>> > at
>> > System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage
>> > msg) 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 Greeting.RemoteHandlerBase.Alert(String s)
>> > at RemoteAlert.Invoke(String str)
>> > at Greeting.Greeter.raise_RemoteAlertEvent(String i1)
>> > at Greeting.Greeter.Alert(String s)
>> > at GreetingServer.Server.Alert_Click(Object sender, EventArgs e)
>> > at System.Windows.Forms.Control.OnClick(EventArgs e)
>> > at System.Windows.Forms.Button.OnClick(EventArgs e)
>> > at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
>> > at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
>> > button, Int32 clicks)
>> > at System.Windows.Forms.Control.WndProc(Message& m)
>> > at System.Windows.Forms.ButtonBase.WndProc(Message& m)
>> > at System.Windows.Forms.Button.WndProc(Message& m)
>> > at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
>> > at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
>> > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
>> > msg, IntPtr wparam, IntPtr lparam)
>> >

-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
http://www.kmsys.com
.


Quantcast