[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Changing timeout for an HttpClientChannel

Tim Werth

7/2/2004 1:40:00 PM

Is there anyway to change the timeout for a registered HttpClientChannel at
runtime? How do I even go about getting the timeout setting
programmatically for the channel at runtime? I've tried the Properties
property, but could only get proxyName and proxyPort. I can see the
_timeout value when I evaluate the channel in the debugger. But how to I
access it programmatically? Is it read-only at runtime?

I have found that sometimes making a remoting call results in a hang
(default timeout period is indefinite). Most of the time, the call times
out in about 5 seconds and says something like "the underlying connection
could not be reached". But sometimes, the call just hangs. I can change
the timeout period when I create the channel, but I don't want to limit the
call time on a connection that is reachable.

So, what I was thinking about doing was to use a channel that has a
relatively short timeout period to use a quick 'ping' call to the remote
machine before I do the real call that would take longer on a channel with
the indefinite timeout (that is if the ping doesn't timeout).

Perhaps the solution is to kill the channel with the indefinite timeout,
create a new one with a short timeout, make the ping call, kill the short
timeout channel, re-create the indefinite timeout channel, make the real
call. But this just smells like it would kill performance, not to mention
my objects are in COM+, so I wouldn't want to clobber one channel in a
object while another object is using it.

Does anyone have a solution for this problem? Can anyone tell me why the
call hangs sometimes?

Tim


1 Answer

Sunny

7/2/2004 2:58:00 PM

0

Hi Tim,

what you can do is to make an async call for your test methods, and then
wait the specified time.

.... I''m skipping the delegate creation ....

IAsyncResult ar;
ar = deleg.BeginInvoke(....)
if (!ar.AsyncWaitHandle.WaitOne(5000, false))
{
//here we know that method have not returned in 5 seconds
}
else
{
//method success
}

Sunny


In article <OjNVHoDYEHA.3520@TK2MSFTNGP10.phx.gbl>,
twerth@onlineziimaging.com says...
> Is there anyway to change the timeout for a registered HttpClientChannel at
> runtime? How do I even go about getting the timeout setting
> programmatically for the channel at runtime? I''ve tried the Properties
> property, but could only get proxyName and proxyPort. I can see the
> _timeout value when I evaluate the channel in the debugger. But how to I
> access it programmatically? Is it read-only at runtime?
>
> I have found that sometimes making a remoting call results in a hang
> (default timeout period is indefinite). Most of the time, the call times
> out in about 5 seconds and says something like "the underlying connection
> could not be reached". But sometimes, the call just hangs. I can change
> the timeout period when I create the channel, but I don''t want to limit the
> call time on a connection that is reachable.
>
> So, what I was thinking about doing was to use a channel that has a
> relatively short timeout period to use a quick ''ping'' call to the remote
> machine before I do the real call that would take longer on a channel with
> the indefinite timeout (that is if the ping doesn''t timeout).
>
> Perhaps the solution is to kill the channel with the indefinite timeout,
> create a new one with a short timeout, make the ping call, kill the short
> timeout channel, re-create the indefinite timeout channel, make the real
> call. But this just smells like it would kill performance, not to mention
> my objects are in COM+, so I wouldn''t want to clobber one channel in a
> object while another object is using it.
>
> Does anyone have a solution for this problem? Can anyone tell me why the
> call hangs sometimes?
>
> Tim
>
>
>