Setting timeout on channel

Cant figure how to change timeout here

constructor ServerAccess;
begin
self._serverUrl := “http://localhost:8099/BIN”;
self._clientChannel := ClientChannel.ChannelMatchingTargetUri(self._serverUrl);
self._message := Message.MessageMatchingTargetUri(self._serverUrl);
end;

Oxygene client

best regards.

Hello

ClientChannel.ChannelMatchingTargetUri returns IClientChannel representing client channel instance with all properties (except TargetUrl) set to their default values. This is the very base interface type for all client channels (note that some of them do not expose a Timeout property at all).

If you need to fine-tune the ClientChannel instance then it might be more feasible to create it explicitly. F.e. in your case it would be

///self._clientChannel := ClientChannel.ChannelMatchingTargetUri(self._serverUrl);
var clientChannel := new IpHttpClientChannel();
clientChannel.TargetUrl := self._serverUrl;
clientChannel.Timeout := .....
self._clientChannel := clientChannel;

Regards

1 Like

Timeout have no effect. It still takes several seconds

constructor ServerAccess;
begin
  self._serverUrl         := "http://localhost:8099/BIN";
  self._clientChannel     := nil;
  self._message           := nil;    
  self.create_serverchannel_and_message;  
end;

method ServerAccess.create_serverchannel_and_message;
begin
  self._clientChannel     := nil;
  self._message           := nil;
  var clientChannel := new IpHttpClientChannel();
  clientChannel.TargetUrl := self._serverUrl;
  clientChannel.Timeout   := 5;
  self._clientChannel     := clientChannel;
  Console.WriteLine(' Channel timeout set to ' + clientChannel.Timeout.ToString);
  self._message           := Message.MessageMatchingTargetUri(self._serverUrl);
end;

What do you want to achieve by setting timeout to just 5 seconds?

If server dont give an answer in 5 seconds get out. Is not possible?

After the timer is elapsed the corresponding socket is commanded to be closed. Then it might take some time for the socket to actually close, especially on Mono or during a SSL handshake.

The server is not running at all. It takes 80 seconds, seems like somethings is wrong with the timeout property.

BTW can please refresh me, in elements, me how to put a block code running even if you exit of a method?

PS. Maybe theres some quick way to check if a port is open at IP address? And i cant do that quick check ,

yes, theres something very wrong on the code.

Hello

The code pauses its execution in the Socket.Connect method. Unfortunately .NET platform does not provide any way to manage the Socket connection timeout.

I’ll log an issue to investigate if it is possible to somehow work around this, however this might take time.

Regards

Logged as bugs://D19251.