You are not logged in.
Pages: 1
Hi,
I am using mORMot for Android client (FPC 3.1.1 r30739). I have problem when server is unavailable (for TSQLHttpClientWebsockets/TSQLHttpClientWinSock).
aClient := TSQLHttpClientWebsockets.Create(cfg.IP, cfg.Port, aModel);
aPerson := TSQLperson.Create(aClient, someID); // this line is freezing application for more than 60 sec
In windows client all works fine (the client application does not stop on the line mentioned above). Anyway i found solution (maybe not perfect but now is possible to set timeout in overloaded constructor in TSQLHttpClientWinSock). Patch attached:
https://drive.google.com/file/d/0B4PZhd … sp=sharing
best reagrds,
Maciej Izak
Last edited by hnb (2015-06-19 11:05:18)
best regards,
Maciej Izak
Offline
Should be included by http://synopse.info/fossil/info/ce16c554f7
Thanks for the input!
Offline
Why you have added ConnectTimeout optional parameter only for TSQLHttpClientRequest? I need ConnectTimeout for TSQLHttpClientWebsockets/TSQLHttpClientWinSock .
best regards,
Maciej Izak
Offline
Indeed.
Please try http://synopse.info/fossil/info/f673bbed94
Offline
Now works perfect. Even SendTimeout and ReceiveTimeout in TSQLHttpClientWinSock.InternalCheckOpen is now covered.
Thanks.
best regards,
Maciej Izak
Offline
@hnb
According to your experience, what are sensible values for the three timeouts on Android ?
Offline
@AOG
From my experience the best values for release for production (in WiFi network) are:
const
DEFAULT_CONNECT_TIMEOUT = 3000;
...
AClient := TSQLHttpClientWinSock.Create(AIP, APort, GModel,
SynCrtSock.HTTP_DEFAULT_SENDTIMEOUT, SynCrtSock.HTTP_DEFAULT_RECEIVETIMEOUT, DEFAULT_CONNECT_TIMEOUT);
In addition if connection is successful I have dedicated thread (and client GClientPing - created with the same parameters as presented above) for ping purposes (online/offline status):
const
PING_MS_DELTA = DEFAULT_CONNECT_TIMEOUT;
...
class function TSyncProcess.TSync.Ping: Boolean;
var
LNow, LThen: TDateTime;
LTryPing: Boolean;
begin
LNow := TimeLogToDateTime(GClientPing.ServerTimeStamp);
LThen := TimeLogToDateTime(FLastPingTimeStamp);
LTryPing := (FLastPingTimeStamp = 0) or (MilliSecondsBetween(LNow, LThen) > PING_MS_DELTA);
if LTryPing or FLastPingResult then
begin
try
Result := GClientPing.ServerTimeStampSynchronize;
except
Result := False;
end;
Result := Sync.StatusCodeIsSuccess(GClientPing) and Result;
FLastPingResult := Result;
FLastPingTimeStamp := GClientPing.ServerTimeStamp;
end
else
Result := FLastPingResult;
end;
best regards,
Maciej Izak
Offline
@hnb
Thanks for your info. Will use your settings.
(about your code-snippet: nice, but why a class function with a GClientPing that must have been created somewhere ?)
While we are discussing Android, I have a few more Android related questions. I would appreciate your opinion.
How do you handle off-line functionality ?
I am now doing the following:
On the Android device itself, I have a slave database that is a slave of the remote master database.
The app always connects with this slave, unless there is a connection available with the master.
Problem: the slave database can be read by anybody with some hacking knowledge (master is safe and can be ecrypted).
Main question:
How to handle off-line behavior in a secure way, while not loosing to much functionality ?
On mobile, off-line behavior is very important !
Offline
@AOG:
GClientPing is a global variable and is created together with regular clients (at application startup). I need that because TSQLHttpClientWinSock is not thread safe. I have few threads in application:
1. GUI
2. Data sync
3. Ping
About security: I have private WiFi network in each place where my application is used. Additionally is used standard hcSynShaAes for data compression.
About functionality, look at new topic:
http://synopse.info/forum/viewtopic.php?id=3569
Last edited by hnb (2016-09-30 21:45:14)
best regards,
Maciej Izak
Offline
Pages: 1