#1 2014-10-07 15:52:23

jaclas
Member
Registered: 2014-09-12
Posts: 215

CrossPlatform and Connection Timeout problem

Hi,

I'm trying to use CrossPlatform client and encountered a problem when I need to define Connection Timeout.
When I do not set Connection Timeout on Android then the connection to the server off (eg. when server is down) lasts nearly seven minutes! During this time an application is not responding (is suspended). I found a place where it should be set Connection Timeout.

In unit SynCrossPlatformSpecific.pas, in procedure TIndyHttpConnectionClass.URI():

    fConnection.ConnectTimeout := MY_CONNECTION_TIMEOUT_VALUE;     //in this place I add my code
    if Call.Verb='GET' then // allow 404 as valid Call.OutStatus
      fConnection.Get(fURL+Call.Url,OutStr,[HTML_SUCCESS,HTML_NOTFOUND]) else
    if Call.Verb='POST' then
      fConnection.Post(fURL+Call.Url,InStr,OutStr) else
    if Call.Verb='PUT' then
      fConnection.Put(fURL+Call.Url,InStr) else
    if Call.Verb='DELETE' then
      fConnection.Delete(fURL+Call.Url) else
      raise Exception.CreateFmt('Indy does not know method %s',[Call.Verb]);

This setting causes the application returns control at the specified time.
Is possible to add properties to these settings at TSQLRestClientURI? And then pass them along with other parameters by TSQLRestURIParams? Or in any other similar manner?

Another option is to provide your own implementation TAbstractHttpConnection class, by indicating the type of class in any other way than by the following function:

function HttpConnectionClass: TAbstractHttpConnectionClass;
begin
  result := TMyHttpConnectionClass;
end;

Maybe it would be good to put this function in the TSQLRestClientHTTP class?

TSQLRestClientHTTP = class
[...]
public
  function HttpConnectionClass: TAbstractHttpConnectionClass; virtual;
end; 

Or pass it as a procedural type?

type
 TAbstractHttpConnectionClassFunction = function HttpConnectionClass: TAbstractHttpConnectionClass;

TSQLRestClientHTTP = class
private
 fHttpConnectionClassFunction : TAbstractHttpConnectionClassFunction;
[...]
public
 property HttpConnectionClassFunction : TAbstractHttpConnectionClassFunction write fHttpConnectionClassFunction;
end;

The same applies to the Read Timeout parameter.

best regards
Jacek

Offline

#2 2014-10-07 17:25:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: CrossPlatform and Connection Timeout problem

Nice idea.

Should be implemented by http://synopse.info/fossil/info/fbe68455aa

Offline

#3 2014-10-08 20:25:01

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: CrossPlatform and Connection Timeout problem

Thx :-)

Offline

Board footer

Powered by FluxBB