#1 2013-04-26 18:11:30

jonsafi
Member
Registered: 2011-07-26
Posts: 58

Getting BatchAdd/BatchSend to work in a C/S environment...

Hello,

For some reason am not getting the addition of records via batch
to a client server (HTTP, No Ajax or Web) to work.

Immediate updates to another table do work though.

The following call returns 0 so it seems to work:

indx  := GG_globalClient.BatchAdd(d_TableInstance, true);

The following call returns 200 so it would seem to work,
but on closer inspection
AllResults[0] and  AllResults[1] are returning 0,
so there seems to be a problem.
However, cannot figure out how to find out the
cause of this error?

Var
AllResults: TIntegerDynArray;
BEGIN
ix := GG_globalClient.BatchSend(AllResults);
GG_globalClient.Commit;

Made sure the server is working properly.
The client starts as follows:

GG_globalClient := TSQLHttpClient.Create('someIP',
                       '888', GG_Model);

Would be very grateful for your pointers over here.
Sami

Offline

#2 2013-04-26 19:03:36

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

Re: Getting BatchAdd/BatchSend to work in a C/S environment...

If you use regular Add instead of BatchAdd?

Do you begin the transaction?

Do you have full code to reproduce?

Did you try to put a breakpoint on the server, then step into the code and find what is wrong?

Offline

#3 2013-04-27 05:30:56

jonsafi
Member
Registered: 2011-07-26
Posts: 58

Re: Getting BatchAdd/BatchSend to work in a C/S environment...

Thanks for your pointers, in fact, it turns out that
only one of the tables works with regular Add
(both have a similar structure though)
and none of them will work with
TransactionBegin:

GG_globalClient.TransactionBegin(TSQLTable1);

causes a mysterious 'Exception class EOSError'
with message 'System Error. Code 12152,
apparently generated from InternalGetInfo32 in
TWinHttpAPI.Request in the unit SynCrtSock

The server code is very simple:

Try
aProps := TSQLDBSQLite3ConnectionProperties.Create(ChangeFileExt(paramstr(0),'.db'),'','','');
  VirtualTableExternalRegisterAll(aModel,aProps);
  Try
    aModel := get_model_HEVDB; // tbls defined in unit HEVDB

   DB :=   TSQLRestServerDB.Create(aModel,'Hev.DB3',
                    CHECK_USERS); 
        DB.CreateMissingTables;
      Try
      aServer := TSQLHttpServer.Create('888',[DB]);

          Write('Press [Enter] to shut down server.');
     finally
        aServer.Free;
      end;
    finally
      aModel.Free;
    end;
  finally
    aProps.Free;
  

To step down code in the server would require attaching some event handler to
the server,  I guess?

Offline

#4 2013-04-27 08:10:15

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

Re: Getting BatchAdd/BatchSend to work in a C/S environment...

Do you use the latest 1.18 'unstable' version?

See http://synopse.info/fossil/wiki?name=Get+the+source

You are wrongly calling VirtualTableExternalRegisterAll() I suppose.
You are calling it on a model, then retrieve another TSQLMOdel instance...
weird...

Offline

#5 2013-04-27 09:12:39

jonsafi
Member
Registered: 2011-07-26
Posts: 58

Re: Getting BatchAdd/BatchSend to work in a C/S environment...

Thanks for the tip, now realize had moved
VirtualTableExternalRegisterAll(aModel,aProps)
too high in the code, it was supposed to just be before
TSQLRestServerDB.Create().
Will try instead

  Try
    aModel := get_model_HEVDB; // tbls defined in unit HEVDB
VirtualTableExternalRegisterAll(aModel,aProps);

Had downloaded the   latest 'unstable' 1.18  version,
but there was a D2009 issue at compilation,
(will try to reproduce it and post it)
so went back a little in history...

Offline

#6 2013-04-27 09:38:19

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

Re: Getting BatchAdd/BatchSend to work in a C/S environment...

I suspect the D2009 compilation has been fixed some days ago.

I mean http://synopse.info/fossil/info/de0ce78f83

Offline

#7 2013-04-27 15:01:17

jonsafi
Member
Registered: 2011-07-26
Posts: 58

Re: Getting BatchAdd/BatchSend to work in a C/S environment...

Thanks for this info, now compiled latest unstable version with no problem.

Can now finally add data to the server tables, (not using batch yet)
however, when stepping on the statement:

GG_globalClient.TransactionBegin(TSQLMyTable2)

still get the error Exception class EOSError' with message 'System Error. Code 12152
which apparently means the following:

HTTP Status 12152 The server has been taken down momentarily for database or server maintenance, or there has been a network error. This status will generally come up when attempting to upload.

Wonder if you have any ideas on this?

Offline

#8 2013-04-27 17:32:17

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

Re: Getting BatchAdd/BatchSend to work in a C/S environment...

Could you run the server application in the IDE debugger, then check out if there is no exception on the server side?

Offline

#9 2013-04-27 18:55:58

jonsafi
Member
Registered: 2011-07-26
Posts: 58

Re: Getting BatchAdd/BatchSend to work in a C/S environment...

When running the server under the debugger, then
at the following statement

      aServer := TSQLHttpServer.Create('888',[DB]);

got an error saying that administrator rights
needed for 'root'. The error does *not* appear
when the server is started normally outside the IDE.

Tried running the application as the administrator, and
it seems to work now.
Am in the habit of avoiding working under the administrator
account (for protection against malware).

Would not have guessed this to be the issue, so thank you so much
for your kind assistance!

Offline

#10 2013-04-27 20:43:34

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Getting BatchAdd/BatchSend to work in a C/S environment...

You must regisre server first

 THttpApiServer.AddUrlAuthorize('root','888',false,'+')); 

Please see this topic http://synopse.info/forum/viewtopic.php?id=1059 and blog post http://blog.synopse.info/post/2011/03/1 … ode-server
See also http://synopse.info/forum/search.php smile

Last edited by mpv (2013-04-27 20:50:42)

Offline

#11 2013-04-28 07:00:29

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

Re: Getting BatchAdd/BatchSend to work in a C/S environment...

... and the SAD pdf documentation!

This is not a limitation of mORMot, but a security feature of the http.sys kernel-mode server it uses.

Offline

#12 2013-04-28 09:37:46

jonsafi
Member
Registered: 2011-07-26
Posts: 58

Re: Getting BatchAdd/BatchSend to work in a C/S environment...

Thanks a lot! Felt that something was missing but could not figure out what. smile

The client can now run successfully w/o having
to run as 'admin'  (am using localhost on a single PC)

However, when it doesn't run as admin, seems to be slower...

Offline

#13 2013-04-28 10:58:36

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

Re: Getting BatchAdd/BatchSend to work in a C/S environment...

Yes http.sys based server is faster than the one based on winsock.

Offline

Board footer

Powered by FluxBB