You are not logged in.
Pages: 1
I am having custom Record
const
__TRECApplicationSetting= 'Port:integer;RootURI:RawUTF8;AutoStart:Boolean;AllowedFileExtension:RawUTF8;Token:Rawutf8';
In Mormot 1 , this is working.
TTextWriter.RegisterCustomJSONSerializerFromText(typeinfo(TRECApplicationSetting),__TRECApplicationSetting).Options:= [soReadIgnoreUnknownFields, soWriteHumanReadable];
Please tell me how to convert the following in Mormot2 ?
Thank you
Offline
Thank You @ab.
I tried, but I got the error ERttiException "Text definition covers 17 bytes but RTTI defined 25.
I see that if I don't define TRttiJson.RegisterFromText( ) then it is working as expected without any problem. So the problem is resolved.
Last edited by srp (2021-10-31 13:31:28)
Offline
Your text definition (__TRECApplicationSetting) does not match the record definition type.
Some fields are missing (may be two pointers/integers or a double/Int64).
If you don't register it, on Delphi 2010 and later, the framework will use the RTTI so it is not mandatory to call Rtti.RegisterFromText().
On FPC or older Delphi, there is no such extended RTTI for record, and RegisterFromText() is needed.
Online
In Mormot 1 this is working as expected and is raising the exception when the port is consumed by any other service.
Try
HTTPServer := TSQLHttpServer.create(777),[RestSrvr]);
Except
on e:ECrtSocket do
ShowMessage('Port is already in use. Please check if any other program is using this port and restart this Service.');
End;
In Mormot 2 this is not working as expected and is not raising the exception when the port is consumed by any other service.
try
HTTPServer :=TRestHttpServer.create(777,[FRestSrvr]);
Except
on e: ECrtSocket do
ShowMessage(e.message);
End;
Can you please guide me if I am doing it wrong? Is there some way to see if the RestHttpserver has started?
Thank You
Last edited by srp (2021-11-13 11:26:12)
Offline
On Windows with http.sys, I have a ENetSock with the expected 'Another process may be currently listening to this port! TCrtSocket.OpenBind(0.0.0.0:777) [Fatal Error - #6]' message.
But with the new async server (e.g. on Linux or on Windows if http.sys URI has not been registered) then there was a waiting loop with no exception.
I tried to fix it with my latest commit.
Note that for socket-based server (i.e. non http.sys - also in mORMot 1 IIRC) the binding is done in the server background thread so the exception may not be reflected in the main thread directly.
Online
Thank You for looking into it @ab
I updated the new changes you made. However, the problem still exists.
In the debug mode, the exception is raised and handled by the Debugger exception. However, when I try running in Administrator mode (http.sys) or the normal mode, the exception is not being raised still.
Offline
Perfect !!!! It is working as expected.
Thanks, @ab for your support
Does it make sense in having a read-only property for the RestHttpServer that exposes the current state (ExecuteState (THttpServerExecuteState)) of the HTTP Server?
Also, in general, Is it better that I start a new thread when I have a specific issue?
Last edited by srp (2021-11-14 06:06:44)
Offline
There is already the ExecuteState property at THttpServerSocketGeneric level, AFAIK.
About the forum, you are right, it is always better to stard a new thread with a dedicated title, for each issue.
It would be easier to follow and find.
Online
Pages: 1