#1 2013-07-02 17:08:12

KJames
Member
Registered: 2013-07-02
Posts: 15

mORMot through internet

I'm using mORMot in a server in cloud (something like Amazon EC2), and my clients connect to the server through the internet.
The internet connection ain't perfect, so sometimes there is instability (a few seconds, usually), when that happens the client application freezes over waiting for the connection with the server.

How can we prevent something like that?

I've tried set a timeout on the connection but I couldn't make it work properly.

Any idea?

Offline

#2 2013-07-03 05:38:20

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

Re: mORMot through internet

This is due to blocking access to the HTTP client.

Could be related to http://synopse.info/forum/viewtopic.php?id=1333

Or changing the SynCrtSock.pas unit to handle properly UI messages during connection attemps...

Online

#3 2013-07-03 11:59:13

KJames
Member
Registered: 2013-07-02
Posts: 15

Re: mORMot through internet

Wich one is easier to implement?


Do you want me to create a ticket?

Offline

#4 2013-07-03 13:06:47

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

Re: mORMot through internet

I do not know which one is the better in the long term.

Worth a ticket as feature request, in all cases.

Online

#5 2013-07-03 13:35:48

KJames
Member
Registered: 2013-07-02
Posts: 15

Re: mORMot through internet

Offline

#6 2013-07-03 17:46:20

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

Re: mORMot through internet

OK

Let's implement it.

I've an idea to add an "Idle" callback event at TSQLRestClientURI level, which will use a background thread for the actual blocking communication, then run the "Idle" callback in loop, to maintain the application UI.
Of course, this callback will have a timing parameter, to allow displaying a popup window to help waiting.
Is it OK for you?

Online

#7 2013-07-04 12:19:16

KJames
Member
Registered: 2013-07-02
Posts: 15

Re: mORMot through internet

I agree, let's do it!

Offline

#8 2013-07-04 12:51:46

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

Re: mORMot through internet

I've just implemented it with http://synopse.info/fossil/info/d86d7dceb2.
Nice show-case of Delphi TThread and TEvent classes, by the way.
smile

See also the ticket description, and our new blog article:
http://blog.synopse.info/post/2013/07/0 … responsive

We tested it with a 3 second artificial temporizer for each request, and the applications were running smoothly, even if slowly - but comparable to most web applications, in fact. The SynFile main demo (available in the SQlite3\Samples\MainDemo) folder defines such a callback.

Hope it fits your needs.

Online

#9 2013-07-04 13:40:31

KJames
Member
Registered: 2013-07-02
Posts: 15

Re: mORMot through internet

Very well, thank you very much.

Offline

#10 2013-07-05 12:23:48

KJames
Member
Registered: 2013-07-02
Posts: 15

Re: mORMot through internet

I was doing some testing and found that when a command is done very quickly, and there's no time to client retrieve the data from the server, and due of the use of threads, the client continues running the code, so that can result sometimes in "Access Violation" and "Invalid pointer operation" errors.

How can we treat this kind of behavior?

Offline

#11 2013-07-05 12:51:33

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

Re: mORMot through internet

We tested it also locally, with immediate result, with no such issue.

I was not able to reproduce this problem.

Online

#12 2013-07-05 13:13:07

KJames
Member
Registered: 2013-07-02
Posts: 15

Re: mORMot through internet

It happens with slower connections. Locally it's just too fast to cause this problem.

Offline

#13 2013-07-06 08:39:01

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

Re: mORMot through internet

We added a 3 second delay per request, on the server side, to simulate very slow network.
It could be close to what you may have at worth...

Did you update all units of mORMot to the latest unstable version?

Since we are not able to reproduce the problem, please describe where the AV occur (source code line number), and context (stack trace).
Best is to provide some simple source code to reproduce the issue.

Online

#14 2013-08-04 19:16:11

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

Re: mORMot through internet

Thanks also for this.

I was using using the new OnIdle event to catch exceptions, checking the LastErrorCode when ElapsedMS = -1.

This doesn't seem possible with the latest implementation. Is there another way to globally check the LastErrorCode?

Offline

#15 2013-08-04 20:36:03

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

Re: mORMot through internet

I suspect OnIdle is not the place to put such process.

Its purpose is to handle notification, not interaction.

Online

#16 2013-08-05 05:15:46

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

Re: mORMot through internet

Yes, I was trying to find a shortcut but now see this isn't so ok.

I've got a connected problem. I'm trying to set TSQLHttpClient.WinAPI.ConnectTimeout before a connection is made but get an AV as WinAPI is only created the moment the first connection is made. Is there a way round this? My test code is:

  DB := TSQLHttpClient.Create('192.168.99.99', '80', TSQLModel.Create([]));//non-existant server
  DB.WinAPI.ConnectTimeout := 5000;
  DB.ServerTimeStampSynchronize;

Offline

#17 2013-08-05 08:01:41

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

Re: mORMot through internet

Set DB.WinAPI.ConnectTimeout := 5000; after the first DB.ServerTimeStampSynchronize;

Online

#18 2013-08-05 09:05:43

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

Re: mORMot through internet

My network can be somewhat unreliable at times (I suspect a DNS problem but don't control the network).

If I set the DB.WinAPI.ConnectTimeout after DB.ServerTimeStampSynchronize; It can take 21 seconds before I get a timeout error (code 12002) but this is intermittent. (Also I find that the maximum timeout I can set is 21 seconds which maybe to do with Windows 7)

So ideally I would like to set  DB.WinAPI.ConnectTimeout before DB.ServerTimeStampSynchronize; to avoid a possible 21 second wait.

Offline

#19 2013-08-07 04:14:32

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

Re: mORMot through internet

Hi, I've got a problem with setting

 CanSelect := False; 

within a TSQLTableToGrid.OnSelectCell procedure when onIdle is set.

If TSQLTableToGrid.OnSelectCell contains these lines

TSQLHttpClient(Database).ServerTimeStampSynchronize;
  CanSelect := False;

it is still possible to select rows by clicking but not by pressing the up and down keyboard buttons. If TSQLRestClientURI.onIdle is nil or the database call in onSelectCell is removed it works - ie clicking on a row doesn't select it. Any ideas where this is going wrong? Thanks

Offline

Board footer

Powered by FluxBB