#1 Re: mORMot 2 » Exceptions when executing custom functions on the external tables » 2026-05-25 09:33:58

I have discovered this method: TOrmServer.setStaticVirtualTableDirect. By calling setStaticVirtualTableDirect(false), now TOrmClass can set the correct table name

#2 Re: mORMot 2 » Exceptions when executing custom functions on the external tables » 2026-05-25 08:54:54

It seems that we don't necessarily need to specify TRestStorageExternal. The MainEngineList can completely perform external table statement queries.

#3 Re: mORMot 2 » Exceptions when executing custom functions on the external tables » 2026-05-25 08:43:21

My tracking and debugging revealed that at line 1105 of mormot.orm.server, in the TRestOrmServer.EngineList function, if a correct Tormclass is specified or if it is left as null, the result of InternalAdaptSql is: rest := TRestStorageExternal, and subsequently, rest.EngineList will be executed. And when a wrong but existing TOrmClass is filled in, then Rest is nil and the mainEngineList will be executed.
  However, for my current application, it is actually necessary to execute the 'mainEngineList' to obtain the desired result, as it is a custom SQLite function.

#4 Re: mORMot 2 » Exceptions when executing custom functions on the external tables » 2026-05-25 08:24:44

the error is :
   TSqlDBOleDBConnection:OleDB error [](0x80040E14)- (line 1):'hzpy' is not a recognized built-in function name. in file 'mormot.db.sql.oledb.pas' at line 1894:

TEmploy:ID(map to External empid):integer;code,name:RawUtf8;
TTrader: ID(map to external traderId):Integer;code,name,phone:RawUtf8;

My RestServer class uses TRestServerDb. External database:mssql 2012,
I used sql: select rowid as Id,code,name,hzpy(name) as helpcode from employ.
The custom function I created on the built-in SQLite database: Db.RegisterSQLFunction(hzpyfunc,1,'hzpy');

#5 mORMot 2 » Exceptions when executing custom functions on the external tables » 2026-05-25 01:18:06

lfyey121
Replies: 5

I have two Torm classes: TEmploy and TDepartment.
   Both of them are mapped to external tables. Additionally, I have defined a custom function named:“hzpy”, whose function is to obtain the pinyin of Chinese characters.
  In the SOA function, I executed server.server.executeList([aOrmClass], 'SELECT ,ID,code,name,hzpy(name) FROM employ), and when aOrmClass is TEmploy or is an empty value, an error occurs, indicating that the hzpy function definition for this external database does not exist. However, when aOrmClass takes on other values, such as TDepartment, the code will execute correctly instead. By tracing the code, I found that at this point, TRestServerDb.MainEngineList will be executed.  IRestOrm is there any way to directly call the mainEngineList? Or is it that I'm doing something wrong?

#6 Re: mORMot 2 » The https service of mormot2 threw an exception » 2026-05-10 09:01:29

Thank you very much. It worked. This is the first time I have used TLS in MORMOT.
  Finally, it was discovered that the problem was actually RootRedirectToUri. The third parameter was set to false by default, so it never redirected to the address of the static web page.

#7 Re: mORMot 2 » The https service of mormot2 threw an exception » 2026-05-10 03:32:00

Regardless of whether the FORCE_OPENSSL compilation option is used or not, the log shows this error:
   EXC  ESChannel {Message: "<>: HandshakeStep returned 80090327 SEC_E_CERT_UNKNOWN, System Error 87 [ERROR_INVALID_PARAMETER]"} [R0:apiv1pm apiv1auth web] at 81e34c .. /.. /src/orm/mormot.orm.client.pas (378) {8 8.03 4.93 8.3GB/23.8GB 23f00f01}

#8 Re: mORMot 2 » The https service of mormot2 threw an exception » 2026-05-10 03:26:12

Thank you for your reply.
The same certificate file (in our mormot2 server, it was converted from pem to pfx using openssl), after using nginx, the browser can access normally, but there will be an insecure warning.  However, when using our mormot2 server, the browser keeps showing a 400 error: 400 Bad Request.

#9 Re: mORMot 2 » The https service of mormot2 threw an exception » 2026-05-08 09:10:38

In the debugging mode, this error will occur: SEC_E_CERT_UNKNOWN / error 87. Whether using secTLSSelfSigned or secTls, it is the same. After ignoring the error, the service cannot work properly. I have installed the root certificate on the client computer. Now we need to access it within the local network via HTTPS. I'm not sure what to do.

#10 mORMot 2 » The https service of mormot2 threw an exception » 2026-05-08 08:21:25

lfyey121
Replies: 8

I generated the tls certificate file using mkcert:mkcert 192.168.2.10
   I use TRestHttpServer.Create(port,[restserver...],'+',WEBSOCKETS_DEFAULT_MODE,4,secTLS,'','', HTTPSERVER_DEFAULT_OPTIONS,@vtls), 
when the browser accessed the service via https://192.168.2.10:port, the server reported an error: raised exception class 'ESChannel' with message: recv: Handshake aborted At line 2041 in file mormot.net.sock.windows.inc... ,

#12 Re: mORMot 2 » TAuthUser.ComputeHashedPassword changed » 2025-09-11 09:05:11

In order to initialize the global variable: AuthAdminDefaultPassword, set the initial password before calling the createMissingTable function.

#13 Re: mORMot 2 » TAuthUser.ComputeHashedPassword changed » 2025-09-09 12:48:48

I inherited a subclass from TauthUser, and then made the computeHashedPassword method public, which solved the problem.

#14 mORMot 2 » TAuthUser.ComputeHashedPassword changed » 2025-09-09 12:32:20

lfyey121
Replies: 5

I previously used the TAuthUser.ComputeHashedPassword changed to set the default password, but now this method has changed from public to protected, which makes it impossible to set the default password. Could you please suggest a solution?


  AuthAdminDefaultPassword:=TAuthUser.ComputeHashedPassword('Admin',setting.AdminDefaultPwd);

#15 Re: mORMot 2 » Possibility to skip some values as JSON serialization » 2025-08-31 03:18:56

TTextWriterWriteObjectOption-->  [woDontStoreVoid]

#17 Re: mORMot 2 » A little bit about TDocVariantData. FlattenFromNestedObjects ideas » 2025-04-14 01:35:15

Thank you for your quick response, very great project.
Some apis (aliyun openapi) need to flatten the submitted object if it requires formdata, but it handles arrays with the sequence number of the first element being 1.
Is it possible to define a HandleArrayType=(hatNone=-1,hatZero=0,hatOne=1);
Change the array type of aHandleNestedArray to this HandleArrayType to determine the element sequence number based on the type

#18 mORMot 2 » A little bit about TDocVariantData. FlattenFromNestedObjects ideas » 2025-04-12 12:05:23

lfyey121
Replies: 4

TDocVariantData. FlattenFromNestedObjects whether can increase the transformation as follows:
{“arr":["a","b","c”]}  =>  {"arr.1":"a","arr.2":"b","arr.3":"c"}

#19 Re: mORMot 2 » How Can I Get Column FieldSize when I Use TSQLDBStatement Get ReCord? » 2025-02-15 06:38:23

TSqlDataset is readonly,
  I used the TBufDataset to obtain the json of the dataset through restful api, then passed it into the TBufDataset by the client, edited it in dbgrid, then obtained the delta data and submitted it to the server. All these were processed by the interface-based service.
  Because there is no field size information, I defined the column information directly in the tbufdataset at design time

#20 Re: mORMot 2 » test » 2025-02-13 10:31:42

mormot2test compile error:

Compile Project, Mode: default, Target: D:\fpcupdeluxe_32T\ccr\mORMot2\test\fpc\bin\i386-win32\mormot2tests.exe: Exit code 1, Errors: 1, Warnings: 1
Verbose: Free Pascal Compiler version 3.3.1-17444-g490c431bf9 [2025/02/12] for i386
Verbose: Copyright (c) 1993-2025 by Florian Klaempfl and others
Verbose: Target OS: Win32 for i386
Verbose: Compiling mormot2tests.dpr
Verbose: Compiling .\test.soa.network.pas
Verbose: Compiling .\test.core.data.pas
Verbose: PPU Loading D:\fpcupdeluxe_32T\ccr\mORMot2\packages\lazarus\lib\i386-win32\mormot.net.dns.ppu
Verbose: PPU Source: mormot.net.dns.pas not found
Verbose: PPU Source: ..\mormot.defines.inc not available
Warning: Recompiling mormot.net.dns, checksum changed for D:\fpcupdeluxe_32T\ccr\mORMot2\packages\lazarus\lib\i386-win32\mormot.net.sock.ppu
Fatal: Can't find unit mormot.net.dns used by mormot.net.ldap
Verbose: Compilation aborted

#21 Re: mORMot 2 » How Can I Get Column FieldSize when I Use TSQLDBStatement Get ReCord? » 2025-01-13 03:51:58

I solved this problem by defining the fields of the dataset directly at design time

#22 Re: mORMot 2 » mormot.net.acme error » 2024-10-26 09:00:56

For example, if the certificate expired yesterday (cc.GetNotAfter), your code: Expired := NowUtc-fRenewBeforeEndDays; expired is one month ago, cc.getNotAfter<expired is not valid.

#23 Re: mORMot 2 » mormot.net.acme error » 2024-10-26 08:55:57

Am I wrong? How do I feel that your code will trigger renew after the expiration of rnewBeforeEndDays? My previous program has not triggered after the expiration, and I need to delete all certificate files each time before I can get it again.

#24 Re: mORMot 2 » mormot.net.acme error » 2024-10-26 04:32:26

In TAcmeLetsEncrypt checkCertificates procedure(line 1110), check the expiration date of error code:
  cc. GetNotAfter < expired
should be:
cc.getNotAfter-fRenewBeforeEndDays < NowUtc

#26 Re: mORMot 2 » how to add/change the username and password? » 2024-07-30 10:10:25

Several global variables are defined in the mormot.rest.core unit:AuthAdminDefaultPassword,AuthSupervisorDefaultPassword,AuthUserDefaultPassword。You can set the initial password, and then change the password through the server code

#27 Re: mORMot 2 » One small suggestion: Return values for interface-based services » 2024-07-08 01:34:22

Thank you for your great work!
  I read the source code and in the new method you added: in the InternalInvoke function of the mormot.soa.client unit, when the clientSideInvoked method is invoked in the DoClientCall method, should the parameter "send" be "resp"?

#28 Re: mORMot 2 » One small suggestion: Return values for interface-based services » 2024-07-05 10:07:12

By customizing the Routing class, I changed the format of the returned data to meet my requirements in the web client, but if the same interface needs to work in the pascal client, it should not be recognized correctly. Should there also be a corresponding method in the TRestClientRouting's inheritance class that can customize the data returned by parsing?

#29 Re: mORMot 2 » Where do I start? » 2024-07-04 01:00:44

Kabiri wrote:

I reviewed the mormot2 examples. In the examples, everyone uses the model. sad


Orm model can have no objects;

  TOrmModel.create([ ], arootName)

#30 Re: mORMot 2 » TDocVariantData.GetValueByPath and Arrays » 2024-04-29 01:31:51

Sorry, my mistake, my json file format is corrupted.

#31 Re: mORMot 2 » TDocVariantData.GetValueByPath and Arrays » 2024-04-28 10:26:58

Now IDocDict doesn't work correctly, use "exists" to check for existing keys and always return false

#32 Re: mORMot 2 » Output parameters of the RawUtf8 type are incorrectly displayed » 2023-11-11 00:57:13

不行,我看了返回值的16进制数字,原始字符串:out测试,  返回的16进制表示:6F7574 C3A6C2B5C28B C3A8C2AFC295,正确的UTF8编码:6F7574 E6B58B E8AF95

#33 Re: mORMot 2 » Output parameters of the RawUtf8 type are incorrectly displayed » 2023-11-10 06:32:53

I tried it, but using Utf8ToString(errMsg) didn't solve the problem.
What happens to the RawUtf8 parameter? English can be returned normally.

#34 mORMot 2 » Output parameters of the RawUtf8 type are incorrectly displayed » 2023-11-09 11:41:44

lfyey121
Replies: 4

my code define as follows::

  IUserManage = interface(IInvokable)
  ['{970EB610-FC4B-4A89-9A39-2767A5100F97}']
    function chgMyPwd(oldPwd,newPwd:RawUtf8;hashed:Boolean;out errMsg:RawUtf8):boolean;
  end; 

  If errmsg returns a Chinese string, the client displays it incorrectly, but if errmsg is of type string, the return is correct.

  I don't know why.

#35 Re: mORMot 2 » Failed to decompress the compressed file using GzFile. Procedure » 2023-10-28 07:25:39

When TSynZipDecompressor. Create (d, szcfRaw), the error is: (avail in = 131071 out = 131072)

#36 mORMot 2 » Failed to decompress the compressed file using GzFile. Procedure » 2023-10-28 07:21:06

lfyey121
Replies: 1

I used the following method to extract it,Error on line 880 of mormot.lib.z:Error -3[data error] during TsynZipDecompressor.write process(avail in =131070 out=131072)

function TmainForm.GUnZipFile(aSrcFile, aDestFile: TFileName; aIsFile: Boolean
  ): boolean;
var
  gz: TSynZipDeCompressor;
  s, d: TStream;
  vfn:TFileName;
begin
  try
    s := TFileStreamEx.Create(aSrcFile, fmOpenReadDenyNone);
    try
      if aIsFile then
        vfn:=aDestFile
      else
        vfn:=aDestFile+extractFileName(aSrcFile);
      d := TFileStreamEx.Create(vfn, fmCreate);
      try
        gz := TSynZipDeCompressor.Create(d,szcFzip{, szcfGZ});
        try
          StreamCopyUntilEnd(s, gz);
          result := true;
        finally
          gz.Free;
        end;
      finally
        d.Free;
      end;
    finally
      s.Free;
    end;
  except
    result := false;
  end;
end;

#37 Re: mORMot 2 » Is there a urlEncode/urlDecode function that implements RFC3986 » 2023-10-19 09:41:34

I find using TDocVariantData sortByName, and toUrlEncode can satisfy many platform API calls, if the toUrlEncode can choose encoding rules: use urlEncode or urlencodeName, so much the better

#38 mORMot 2 » Using tsyndaemon when running as a service is very cpu consuming » 2023-10-17 03:05:03

lfyey121
Replies: 0

The service I developed with TsynDaemon has a cpu usage close to zero when running with /c as the console, and 20% when running as a service. I don't know what the problem is, even though I don't have any code in start, the cpu usage is so high. My system is windows10 fpc3.3.1 lazarrus 3.99, mormot2

#39 Re: mORMot 2 » mormot.net.acme error » 2023-10-12 11:23:45

Thank you, https is finally working

#40 Re: mORMot 2 » mormot.net.acme error » 2023-10-12 11:21:51

After many attempts, the ssl_password_file parameter does the job, but strangely, the file name specified after this parameter must be in the standard windows path, and the certificate file specified path must replace the '\' in the path with '//'.

#41 Re: mORMot 2 » mormot.net.acme error » 2023-10-12 09:43:15

gAcmeLetsEncryptServer:=TAcmeLetsEncryptServer.create(TsynLog, TacmeDaemonSettings(settings).keyStoreFolder,
      ACME_LETSENCRYPT_URL{ACME_LETSENCRYPT_DEBUG_URL},'',''{There can be no passwords here},-1,'8084');

#42 Re: mORMot 2 » mormot.net.acme error » 2023-10-12 09:40:56

After the test, you cannot set the password when applying for a certificate. After the password is set, the https service cannot run. After removing the password and re-applying for a certificate, it can run normally

#43 Re: mORMot 2 » mormot.net.acme error » 2023-10-11 12:52:13

d:\sslkeystore\xxx.xx.com.crt.pem;
d:\sslkeystore\xxx.xx.com.crt.pem;

This is the file generated by mormot.net.acme

#44 Re: mORMot 2 » mormot.net.acme error » 2023-10-11 12:48:50

I use nginx, the Settings are as follows, but https is not accessible,, I don't know what the problem is

server {
        listen       443 ssl;
        server_name  xxx.xx.com;
        ssl_certificate      d://sslkeystore//xxx.xx.com.crt.pem;
        ssl_certificate_key  d://sslkeystore//xxx.xx.com.key.pem;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
       

        location / {
            proxy_pass   http://127.0.0.1:81;
            proxy_redirect     default;
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
            proxy_max_temp_file_size 0;
            proxy_connect_timeout      180;
            proxy_send_timeout         180;
            proxy_read_timeout         180;
            proxy_buffer_size          4k;
            proxy_buffers              4 32k;
            proxy_busy_buffers_size    64k;
            proxy_temp_file_write_size 64k;
        }
    }

#45 Re: mORMot 2 » mormot.net.acme error » 2023-10-11 01:07:01

Yes, it works correctly and the certificate file has been generated

thanks

#46 Re: mORMot 2 » CompareMem function problem » 2023-10-08 03:20:50

Thanks
this issue has been solved,
but this mormot.net.acme has found a new issue here, I have submitted a new topic

#47 mORMot 2 » mormot.net.acme error » 2023-10-08 03:14:29

lfyey121
Replies: 17

An error occurred while calling the completedomainregistero function:

   EXC   EJwsHttp {Message:"Error 400 [Error parsing certificate request: asn1: structure error: tags don't match (16 vs {class:0 tag:13 length:45 isCompound:true}) {optional:false explicit:false application:false private:false defaultValue:<nil> tag:<nil> stringType:0 timeType:0 set:false omitEmpty:false} certificateRequest @2] while querying https://acme-v02.api.letsencrypt.org/acme/finalize/1349321746/213579860876"} [CheckCertificates] at 4c4526

#48 Re: mORMot 2 » CompareMem function problem » 2023-10-07 12:45:00

I trace that in asm code, the comparison of the first 4 bytes is already inconsistent

#49 Re: mORMot 2 » CompareMem function problem » 2023-10-07 12:28:06

The received data url:

  /.well-known/acme-challenge/Fx3W3J_cIlgHswjpA_NMDES4GPJ0acGEBHtXaCgTlsM

#50 mORMot 2 » CompareMem function problem » 2023-10-07 12:22:17

lfyey121
Replies: 4

In line 1264 of the mormot.net.acme unit, CompareMem(P, @_ACME_CHALLENGE_PATH, ACME_CHALLENGE_PATH_LEN) executes incorrectly and returns false all the time.

My environment is lazarus 3.99, FPC3.3.1(i386), windows 10

Board footer

Powered by FluxBB