You are not logged in.
Pages: 1
I have a mormot 2.1 server and I am calling methods from an interface
Using postman I call the url with just the name of the URL and without the method
ex The complete URL is http://127.0.0.1:10000/pchr/v8/Restinf/method
where iRestinf is the interface and method is the interface method
when calling then URL http://127.0.0.1:10000/pchr/v8/Restinf/ without the method, I am getting an exception both in Delphi debug mode in mormot.rest.server line 3026
The same code with FPC in linux returns :
<body style="font-family:verdana">
<h1>mORMot2 (Linux) Server Error 500</h1>
<hr>
<p>HTTP 500 Internal Server Error<p>EFastReader: Reached End of Input<p><small>mORMot 2
Offline
No, with a POST
I believe the problem is because I am using a slash / inside the base URI 'pchr/v8'
Last edited by dcoun (2023-03-07 19:59:36)
Offline
20013718 $ - 08.991.005
20230307 20013718 $ ret mormot.rest.server.TRestServerRoutingRest(05404860) { "errorCode":500, "error": {"EOrmException": { "ClassName": "EOrmException", "Address": "cb791a mormot.rest.server.pas TRestServerUriContext.ExecuteCommand (3029)", "Message": "Unexpected Command=0 in TRestServerRoutingRest.Execute" }} }
20230307 20013718 $ srvr ? POST pchr/v8/restInf=500 out=250 B in 8.99s
20230307 20013718 $ debug mormot.rest.memserver.TRestServerFullMemory(052f90c0) TRestServerRoutingRest.Error: { "errorCode":500, "error": {"EOrmException": { "ClassName": "EOrmException", "Address": "cb791a mormot.rest.server.pas TRestServerUriContext.ExecuteCommand (3029)", "Message": "Unexpected Command=0 in TRestServerRoutingRest.Execute" }} }
20230307 20013718 $ EXC EOrmException {Message:"Unexpected Command=0 in TRestServerRoutingRest.Execute"} [R1 pchrv7 pchrv8] at cb791a mormot.rest.server.pas TRestServerUriContext.ExecuteCommand (3029)
20230307 20012819 $ + mormot.rest.memserver.TRestServerFullMemory(052f90c0).URI POST pchr/v8/restInf in=0 B
20230307 20002920 $ - 14.477.594
Offline
So, it is supported only for client side as mentioned in https://synopse.info/forum/viewtopic.php?id=6338 (first response) ?
Last edited by dcoun (2023-03-07 20:13:16)
Offline
I think also, that this is the problem for this too: https://synopse.info/forum/viewtopic.php?id=6491
Offline
Problem exists even with TOrmModel.Root that does not have a slash
Is only one interface allowed per TRestServerFullMemory ? because, I usually have at least two
Offline
Perhaps the error returned after https://github.com/synopse/mORMot2/commit/4ef093bd is more explicit.
You can write as many interface as you want in a single TRestServer.
Perhaps there is a problem with the fact that you have two TRestServer in your HTTP server, and that they have '/' in their Model.Root.
Online
it does not compile with PUREMORMOT2, but at least, it works
Thank you a lot @ab
Offline
the problem here: https://synopse.info/forum/viewtopic.php?id=6491 is not fixed. it is now returning a 400 error
Removing the slash from Tmodel.root did not help, nor anything else.
I have now an other method in the other interface that does not work if compiled with FPC. If compiled with Delphi 11.2, it works without any problem
This method can be just a result assignment to return a result through TServiceCustomAnswer but it stills gives an 500 http error.
I am using Lazarus 2.2.5 (rev lazarus_2_2_4-27-g75ee8b4c01) FPC 3.2.3 x86_64-win64-win32/win64 and cross compiling for Linux but no success with fpc.
Offline
I am not able to reproduce your problem.
It is possible there is something outside mORMot, e.g. in your code, which triggers some memory corruption.
I just run all mormot tests with FastMM4 in FullDebugMode with no issue reported.
Do the same for your own code.
Online
I will try it in windows with FPC, as with Delphi it works OK
But I am not sure it is from my code. I do not have many methods and everything else worked for months till now, without even a restart.
The same interface has an other method with exactly the same code as the problematic method. The only difference is a RetrieveDocVariantArray that uses a different Torm table. No other difference.
both search a different table with the same parameters and return the query results.
I changed in the "working" method the Tormtable used in the query and I got the same problem. I finally succeeded to have the problematic method to work by just removing a search Tdatetime parameter in the query that usually causes the result to be an empty query.
Now it works. I will check it again tomorrow.
Offline
If you can write a https://stackoverflow.com/help/minimal- … le-example or debug on your side the non working method to see what is wrong...
For FPC/Lazarus, use the fpdebug debugger which is much more stable and usable that gdb.
Online
I was travelling and it was not possible to debug it since now. In win64 target, there is no exception. in Linux 64, it happens when the resulted query from RetrieveDocVariantArray is empty.
I will try to debug it more tomorrow.
Offline
I have installed wsl2, ubuntu and I was able to have the exeception in this enviroment.
I installed the FPC for linux to be able to trace it and I found that the exception happens in mormot.soa.server line 1510 when calling
WR.SetText(Ctxt.Call.OutBody);
and especially, in mormot.core.base, line 11548,
FastAssignUtf8(Text, fDataString) // FPC expects this
As far as I can see Text is zero length empty string and FDataString has a value of '[]'.
My method is:
function TinterP.GetOrders(const sdat, edat: rawutf8; const pid: int64): TServiceCustomAnswer;
var ..... sdat_,edat_:RawUtf8; _pid:Int64; v:variant; p:Tid;
begin ..... p:=0; ......
v:=MyTrestserverDB.Orm.RetrieveDocVariantArray(Tormmyorm,'aa','pid=? and sdat>=? AND edat2<=?',[_pid,sdat_,edat_],'RowID,edat,sdat,extra,lastupd',@p);
if p=0 then result:=prepSCA(204,'[]') else result:=prepSCA(200,VariantToUtf8(v.aa));
end;
prepSCA is just a function to return a TServiceCustomAnswer with the arguments.
If the query has results everything is OK. If it is empty an exception happens, only in linux
I am using Lazarus 2.2.7 (rev ada7a90f86) FPC 3.2.3 x86_64-linux-gtk2
Last edited by dcoun (2023-03-10 11:51:54)
Offline
I have tested the function leaving just the if clause and the same happens.
I start the service connecting to a postgres db and this is the first call
Offline
IMHO you should not use RetrieveDocVariantArray but directly the JSON from the DB.
But anyway, please try if https://github.com/synopse/mORMot2/commit/2c2a774b makes a difference.
Online
It started as a copy-paste function. You have right, now I learn from RetrieveDocVariantArray's code, I will change it.
Concerning the problem in this tread, it works now OK and the problem described here https://synopse.info/forum/viewtopic.php?id=6491 is also fixed.
Thank you a lot @ab
Offline
The https://github.com/synopse/mORMot2/commit/2c2a774 fix introduced a regression, in multi-thread context.
I was able to reproduce the problem with the multi-thread tests, and enabling verbose logs, so that process could be a little bit delayed, and multi-thread TRawByteStringStream reuse triggered some unexpected wrong results, due to fDataString string reuse and in-place overwrite. In short, the string returned by the server was not the one processed on the client, because it had sometimes been reused and rewritten for another request in another thread in-between.
Should be properly working now with https://github.com/synopse/mORMot2/commit/8d3dc2b2
I bless our aggressive regression tests to be able to reproduce such issues, and the verbose logs to make the root cause obvious: on production, it could have been awful to debug!
Online
Thank you @ab for your time and your amazing work.
Offline
Pages: 1