#1 mORMot 1 » Sessiontimeout » 2023-04-07 23:04:55

firstfriday
Replies: 1

I am using interfaced rest server WITHOUT Object-Relational Mapping. Only Rest interface.
Like documented the default session is closed after 30 minutes. But since I am not using any of the table operations the session is closed EVEN I use the interface all the time.
How can I set a kind of activity flag?
Thanks

#2 Re: mORMot 1 » DomainHostRedirect not working » 2020-02-03 23:51:02

1) HTTP Host: header is indeed modified by Chrome but also Firefox does modify it.

2) Editing the hosts file
127.0.0.1 images.localhost
does work.

3) Only one thing of understanding is bugging me:
I agree totally with the DNS resolution process. But this should work then:
http://images.<hostname>:8083/test.jpg
hostname=computername. But it also fails.

#3 Re: mORMot 1 » DomainHostRedirect not working » 2020-02-03 06:24:30

1) curl -v http://images.localhost:8083/test.jpg
* Could not resolve host: images.localhost
* Closing connection 0
curl: (6) Could not resolve host: images.localhost
2) maybe thats an option but after 2h of reading the manual I gave up.
3) tried already.
4) http://images.hostname:8083/test.jpg does also not work on this computer other yes

I suppose some problems never get solved or are not worth finding :-(

#4 Re: mORMot 1 » DomainHostRedirect not working » 2020-02-02 05:34:41

These were interesting answers. I (believe) to be closer to the problem.

Very interesting is that
- Chrome Browser CAN access http://images.localhost:8083/test.jpg
- Fire Fox, Edge, ie CAN NOT and
- THTTPClient responds Error sending data: (12007) The server name or address could not be resolved

In my mind this must be a DNS problem while google chrome somehow resolved that on it's own.

With
- "logman.exe start httptrace -p Microsoft-Windows-HttpService 0xFFFF -o httptrace.etl –ets"
you can trace any http requests but no traffic.
- hosts file is empty
- I checked also TCPIP settings for alternative DNS->No

More ideas?

#5 Re: mORMot 1 » DomainHostRedirect not working » 2020-02-01 05:57:42

Thank you for your reply.

Both latest Windows 10.

Unfortunatly no errors and the logs of both computer are identical.

TSynLog 1.18.5499 2020-02-01T04:40:52
image.server.model.TSQLHttpServerroot(056a38f0) http.sys registration of http://+:8083/root
SetThreadName 1130=TSQLHttpServerroot 8083/root THttpApiServer
image.server.model.TSQLHttpServerroot(056a38f0) {"THttpApiServer(05d8d7f0)":{"RegisteredUrl":"http://+:8083/root/","MaxBandwidth":-1,"MaxConnections":-1,"APIVersion":"HTTP API 2.0","ServerName":"mORMot (Windows)","ProcessName":"root "}} initialized for root
image.server.model.TSQLHttpServerroot(056a38f0) Redirect http://localhost:8083 to http://localhost:8083/root
image.server.model.TSQLHttpServerroot(056a38f0) http.sys registration of http://+:8083//

DomainHostRedirect('images.localhost','root/images');

http://localhost:8083/root/images/test.jpg // works on both computers
http://images.localhost:8083/test.jpg  // does not work on one computer, Page not found

I don't think it is related to mormot or my code more because if I set A1) breakpoint

unit SynCrtSock;
...
Err := Http.ReceiveHttpRequest(fReqQueue,ReqID,0,Req^,length(ReqBuf),bytesRead);
if Terminated then // A1) breakpoint here

and call http://images.localhost:8083/test.jpg
the breakpoint is not reached.
I checked also the windows eventlog but there is nothing interesting to find.
How exactly is the way from a browser-call images.localhost to this breakpoint?


BTW:
In Debug-Mode this has no effect:
TSynLog.Family.DestinationPath:='log\';
In Release-mode it does.

#6 mORMot 1 » DomainHostRedirect not working » 2020-01-31 04:15:04

firstfriday
Replies: 15

Hi, I have a Mormot Server written with server.DomainHostRedirect(..) which works on one computer but not on another one.

Same programm on both computers and startet as Admin to register the server.
no error occurs.

Even THttpApiServer.Execute is not executed which leads me to the idea that the https server is not passing the request.
but why? Any ideas where to look?

#8 Re: mORMot 1 » mORmot examples 64-bit on Delphi10.2 fails compiling » 2018-02-22 07:10:46

I installed
- RAD Studio 10.2 Hotfix for Toolchain and
- RAD Studio 10.2.2 Tokyo February 2018 Patch
but no change. IDE hangs. Another idea?

#9 mORMot 1 » mORmot examples 64-bit on Delphi10.2 fails compiling » 2018-02-21 18:02:07

firstfriday
Replies: 6

Hi,
I can compile the examples (SQLite3\Samples) on 32-bit but not on 64-bit.

The compiler hangs during compilation of mormot.pas (started from IDE).
Has anyone the same problem and a solution?

Edgar

#10 Re: mORMot 1 » MySQL Wrong fetchtype with FORWARD ONLY cursor » 2017-05-06 08:39:59

The full code is this:

procedure TMainForm.Button1Click(Sender: TObject);
var
  Props :TODBCConnectionProperties;
  Q: TQuery;
begin
  Props :=TODBCConnectionProperties.Create('','DRIVER=MySQL ODBC 5.3 Unicode Driver;SERVER=localhost;DATABASE=db1;USER=root;PASSWORD=;Port=3306','','');
  Q := TQuery.Create(Props.NewConnection);
  try
    Q.SQL.Clear; // optional
    Q.SQL.Add('select * from table1);
    Q.Open;
    while not Q.Eof do
    begin
      Q.Next;
    end;
    Q.Close;    // optional
  finally
    Q.Free;
  end;
end;

Maybe TQuery is just not meant to use with mySQL. Of cource I could use the Step Command but for legacy purposes this is not an easy job. Or I can override this origin TQuery.

#11 Re: mORMot 1 » MySQL Wrong fetchtype with FORWARD ONLY cursor » 2017-05-05 15:31:42

Thank you for your fast response. I have the latest version and here you see "first" and the end. this causes the error in mySQL.

unit SynDB;

procedure TQuery.Open;
var i, h: integer;
    added: boolean;
    ColumnName: string;
begin
  if fResultCount>0 then
    Close;
  Execute(true);
  for i := 0 to fPrepared.ColumnCount-1 do begin
    ColumnName := UTF8ToString(fPrepared.ColumnName(i));
    h := fResult.FindHashedForAdding(ColumnName,added);
    if not added then
      raise ESQLQueryException.CreateUTF8('Duplicated column name "%"',[ColumnName]);
    with fResults[h] do begin
      fQuery := self;
      fRowIndex := 0;
      fColumnIndex := i;
      fName := ColumnName;
    end;
  end;
  assert(fResultCount=fPrepared.ColumnCount);
  // always read the first row
  First;
end;

I wonder if I can change somehow the cursor type.

#12 Re: mORMot 1 » MySQL Wrong fetchtype with FORWARD ONLY cursor » 2017-05-05 11:06:30

Yes...but my question is:
I use the wrapper TQuery of mormot and unfortunatly inside this function it uses

while i.Step(true) do

I use this TQuery with mssql and it works here but not with mySQL.

#13 mORMot 1 » MySQL Wrong fetchtype with FORWARD ONLY cursor » 2017-05-04 18:38:31

firstfriday
Replies: 7

I would like to use the TQuery wrapper with mySQL but I failed because of this error:

TODBCStatement - TODBCLib error: [HY106] [MySQL][ODBC 5.3(w) Driver][mysqld-5.5.5-10.1.21-MariaDB]Wrong fetchtype with FORWARD ONLY cursor (537)

Reproduction can be easily done by this code
TQuery uses this: while I.Step(true)

  Props :=TODBCConnectionProperties.Create('','DRIVER=MySQL ODBC 5.3 Unicode Driver;SERVER=localhost;DATABASE=testdb;USER=root;PASSWORD=;Port=3306','','');
  I:=Props.Execute('select * from table',[]);
  while I.Step(true) do // < ERROR but while I.Step(false) works!
  begin

  end;

#14 Re: mORMot 1 » new book about mORMot » 2016-12-22 22:27:15

I just got the book. I did not read it fully but it tells you less than the documentation at Synopse. It's a book for beginners. No ORM/SOA/DDD or any deeper concepts. And the layout is not good.
Big font, specially of the code listings (approx. 50% of the book, 100 pages code print of the demos of this website) which have ugly line breaks which makes them difficult to read. Sometimes just one single word on a page. I' am pretty sure nobody looked at it before giving it to the press.
That reminds me of bad copies of Lonely Planet you can buy in Asia on a market.
Somebody "above" wrote the book has a good quality. I really cannot agree with this. At least not my version: Printed in Poland by Amazon Fulfillment.
For almost 60€ I've expected a better quality - far to expensive.

#16 Re: mORMot 1 » Memory Leak when using Parameter in Query with MSSQL » 2016-12-19 09:45:44

Props.UseCache := False;
was the a goog idea! Works now. (yes, it's only a test case)
Thanks

#17 mORMot 1 » Memory Leak when using Parameter in Query with MSSQL » 2016-12-18 13:11:08

firstfriday
Replies: 2

When doing mass insertions with MSSQL (only here, not SQLite) there is a quite big memory loss when using parameters(see Version2).
Without params everything works fine (see Version1).

Code to reproduce:

procedure TForm2.cmdErrorClick(Sender: TObject);
var
  i:integer;
  SQL,s:string;
  Props:TOleDBMSSQL2012ConnectionProperties;
  SQLDBConnection:TSQLDBConnection;
  Query : TQuery;
begin
  (*
    create a mssql database execute this
    create table [dbo].[test] (
      [id] [int] not null ,
      [id_u] [int] null,
      [fkey] [nvarchar] (255) collate sql_latin1_general_cp1_ci_as null ,
      [svalue] [nvarchar] (255) collate sql_latin1_general_cp1_ci_as null ,
      [ivalue] [int] null ,
      [fvalue] [float] null
    ) on [primary]
    go
  *)
  Props:=TOleDBMSSQL2012ConnectionProperties.create('localhost','test_db','sa','');
  SQLDBConnection:=props.NewConnection;

  SQL := 'TRUNCATE TABLE test';
  query:=Tquery.Create(SQLDBConnection);
  query.SQL.clear;
  query.SQL.Add(SQL);
  query.ExecSQL;
  query.free;

  s:='String';
  query:=Tquery.Create(SQLDBConnection);
  for i:=1 to 100000 do
  begin
    //SQL := format('insert into test (id,ivalue,fkey,svalue) values (%d,%d,''%s'',''%s'')',[i,i,s,s]); // Version 1=> works
    SQL := 'insert into test (id,ivalue,fkey,svalue) values (:id,:ivalue,:fkey,:svalue)' ;// Version 2 =>memory leak when executed
    query.SQL.Clear;
    query.SQL.Add(SQL);
    // Version 2
    query.ParamByName('id').AsInteger     :=i;
    query.ParamByName('ivalue').AsInteger :=i;
    query.ParamByName('fkey').AsString   :='String '+inttostr(i);
    query.ParamByName('svalue').AsString :='String '+inttostr(i);

    query.ExecSQL;
  end;
  query.free;
end;

Arnauld, can you fix this?

#18 Re: mORMot 1 » Re-use of TQuery does not work » 2016-12-18 12:10:36

ok, I testet it: With SQLite there is no problem.

After taken the latest version of mormot it is possible to re-use Tquery it with MSSQL.

#19 Re: mORMot 1 » new book about mORMot » 2016-12-18 11:33:59

Great, just ordered it, I am looking forward to it.

For the french guy:
https://www.amazon.de/dp/1517516005/ref … +Databases

#20 Re: mORMot 1 » Re-use of TQuery does not work » 2016-12-18 08:22:18

Thank you for your answer but the query is closed anyway, look:

procedure TQuery.ExecSQL;
begin
  Execute(false);
  Close;
end;

may be it is a problem with mssql?
I will create a sample with sqlite and compare....

#21 mORMot 1 » Re-use of TQuery does not work » 2016-12-17 16:47:19

firstfriday
Replies: 3

Why is it not possibe to use Tquery more than 1 time?
Code to reproduce:

procedure TForm2.cmdErrorClick(Sender: TObject);
var
  i:integer;
  SQL,s:string;
  Props:TOleDBMSSQL2012ConnectionProperties;
  SQLDBConnection:TSQLDBConnection;
  Query : TQuery;
begin
  (*
    create a mssql database execute this
    create table [dbo].[test] (
      [id] [int] not null ,
      [id_u] [int] null,
      [fkey] [nvarchar] (255) collate sql_latin1_general_cp1_ci_as null ,
      [svalue] [nvarchar] (255) collate sql_latin1_general_cp1_ci_as null ,
      [ivalue] [int] null ,
      [fvalue] [float] null
    ) on [primary]
    go
  *)
  Props:=TOleDBMSSQL2012ConnectionProperties.create('localhost','test_db','sa','');
  SQLDBConnection:=props.NewConnection;

  SQL := 'TRUNCATE TABLE test';
  query:=Tquery.Create(SQLDBConnection);
  query.SQL.clear;
  query.SQL.Add(SQL);
  query.ExecSQL;
  query.free;

  s:='String';
  query:=Tquery.Create(SQLDBConnection);
  for i:=1 to 100000 do
  begin
    //SQL := format('insert into test (id,ivalue,fkey,svalue) values (%d,%d,''%s'',''%s'')',[i,i,s,s]); // Version 1=> works
    SQL := 'insert into test (id,ivalue,fkey,svalue) values (:id,:ivalue,:fkey,:svalue)' ;// Version 2 =>memory leak when executed
    query.SQL.Clear;
    query.SQL.Add(SQL);
    // Version 2
    query.ParamByName('id').AsInteger     :=i;
    query.ParamByName('ivalue').AsInteger :=i;
    query.ParamByName('fkey').AsString   :='String '+inttostr(i);
    query.ParamByName('svalue').AsString :='String '+inttostr(i);

    query.ExecSQL;
  end;
  query.free;
end;

#22 mORMot 1 » TOleDBConnection: Not enough storage is available ... » 2016-12-17 16:25:25

firstfriday
Replies: 1

Has anybody encountered this message after inserting records for approx. 1 h:

TOleDBConnection: Not enough storage is available to complete this operation

#23 mORMot 1 » Determine the Field/Datatype of a Query » 2016-12-16 06:52:30

firstfriday
Replies: 1

I ' am using your TQuery wrapper.

How can I find out the datatype of the fields of a query? Similar to the ado function:
Query.Fields[0].DataType

Specially to find out type boolean and memo, text.

SQLDBConnection:=props.NewConnection;
Query := TQuery.Create(SQLDBConnection);
Query.sql.add('select * from mytable');

Query.Fields[0].DataType ???

Thank you

#24 Re: mORMot 1 » Returning HTML » 2015-07-26 10:30:46

uuuuhh, a copy past error, thanks

#25 Re: mORMot 1 » Returning HTML » 2015-07-24 10:16:58

Hallo!
Can anybody help me in this matter?
How can I send content-Type HTML instead of PLAIN TEXT?
Thank you

#26 mORMot 1 » Returning HTML » 2015-07-22 08:50:44

firstfriday
Replies: 3

This is probably easy but this code keeps returning

Content-Type=text/plain; charset=UTF-8

instead of

Content-Type=text/html; charset=UTF-8

procedure TSQLRestServerFullMemory.Help(Ctxt: TSQLRestServerURIContext);
begin
Ctxt.Returns('<html><body>Help</body></html>',HTML_SUCCESS,HTML_CONTENT_TYPE);
end;

Please help
Edgar

Board footer

Powered by FluxBB