all groups > dotnet remoting > june 2005 >
You're in the

dotnet remoting

group:

Server not connected, or connection refused.



Server not connected, or connection refused. Christopher Schipper
6/14/2005 1:24:28 PM
dotnet remoting: I'm working on wiring up some remoting to my website, and have a few
questions I can't seem to find answers for online. For one the server code
below doesn't matter because the question is related to when the server is
OFFLINE.

I'll be calling the remote server from a asp.net page and would like to set
the timeout to <100ms before generating a no server responded to the request
error message.

I've scoured the net and found interesting articles about using async
delegates that didn't work because the exception would be thrown out of
process and cause a jit exception window. (Sorry the testing is being done
via winforms)

So I have read that tcp has no timeout (bummer) and using the http timeout
property does no good for the connection itself (it always times out between
400-600ms regardless of the property setting)

Has anyone been able to limit remoting and set a timeout for establishing a
connection. (NOT execution time)

The goal is to bypass a non critical function in a few ms as there will be
thousands of clients connected and I cannot have them all wait 500ms to
generate exceptions.

Thank you.

ps. I've looked at commercial packages, so please only post a valuable reply
not an advertisement.
____________________________________________________

Client:

Dim objRemote As IAddressData = Activator.GetObject(GetType(IAddressData),
"tcp://localhost:4000/remote.rem")
'Dim objRemote As IAddressData = Activator.GetObject(GetType(IAddressData),
"http://localhost:4001/remote.rem")
'objHTTPChannel.Properties("timeout") = 50

SUB
ListBox1.DataSource = objRemote.GetCityNames(TextBox1.Text)
END SUB

____________________________________________________

Server:
ChannelServices.RegisterChannel(New TcpServerChannel(4000))
ChannelServices.RegisterChannel(New HttpChannel(4001))
RemotingConfiguration.ApplicationName = "RemoteServer"
RemotingConfiguration.RegisterWellKnownServiceType(GetType(SBI.REMOTE.ADDRESS.Server),
"remote.rem", WellKnownObjectMode.Singleton)

Console.ReadLine()

Re: Server not connected, or connection refused. Christopher Schipper
6/15/2005 10:53:36 AM
I have been doing more reading, and think the delegate option would be best,
however there are a few missing links....

Dim dele As New GC(AddressOf objRemote.GetCityNames)
Dim ar As IAsyncResult = dele.BeginInvoke(TextBox1.Text, Nothing, Nothing)
ar.AsyncWaitHandle.WaitOne(50, False)
If ar.IsCompleted = True Then
ListBox1.DataSource = dele.EndInvoke(ar)
End If

system still pauses and blocks during endenvoke.

ar.iscompleted always returns true.

if I use me.begininvoke, I have to handle application.exceptions and
override it to return the exception.

Please advise.


[quoted text, click to view]

Re: Server not connected, or connection refused. Mark Bayless
6/22/2005 10:12:06 PM
Christopher,

I have had a similar problem trying to get a remoting connection to time out quicker. I just found what may be the answer to your problem (sorry for the mixed C# and VB):

Dim objRemote As IAddressData = Activator.GetObject(GetType(IAddressData), "tcp://localhost:4000/remote.rem")

IDictionary prop = ChannelServices.GetChannelSinkProperties
( IAddressData );
prop["timeout"] = 50;

In my test app, the remote method call now returns immediatly instead of taking 90 seconds when there is no remote server available.

Good luck, hope this helps.

Mark

---
Re: Server not connected, or connection refused. Christopher Schipper
6/24/2005 9:25:08 AM
Thank you so much I'll give that a try.

...Update

I've tried it and it worked flawlessly. Thank you Thank you.

I would have swore i've tried that, but obviously not.

Thanks again.

Chris

[quoted text, click to view]

AddThis Social Bookmark Button