#1 mORMot 1 » Equivalence of TObjectListLocked in mormot2. » 2022-11-23 06:21:38

srp
Replies: 1

Can anyone please tell me which class I need to use?
I have used this TObjectListLocked class (syncommons) and i am trying to move to Mormot2. 

Thank You

#2 mORMot 1 » Zero Length handling in FileFromString » 2021-11-25 11:39:39

srp
Replies: 1

Expected Result from FileFromString('','d:\1.pdf') is False
but the function Result is True and created a file with Zero Length.

Is this Expected Behaviour?


Thank You.

#4 Re: mORMot 1 » Loading & Creating from a TRestHttpClient Definition file ? » 2021-11-24 03:56:28

srp

Thank You @dcoun for confirming.
Thank You @esmondb.  Will definitely go through the book

I further investigated and think the error is at this point  'mormot.rest.core' at line 1934.

constructor TRest.RegisteredClassCreateFrom(aModel: TOrmModel;
  aDefinition: TSynConnectionDefinition; aServerHandleAuthentication: boolean);
begin
  Create(aModel);
  // ADefinition  should be used / assigned at this point.
end;


Edit :  I am wrong.

@dcoun you are spot on. I checked and  if I make  the change in line  2368  of mormot.net.client from

  if fProxyName = '' then

to

if (fProxyName = '')  or (fProxyName = '=''''') then

.

It works as expected.

Thank You

#5 Re: mORMot 1 » Loading & Creating from a TRestHttpClient Definition file ? » 2021-11-22 13:42:47

srp

Thank You @Ab for the reply. 

I  tried hard for hours to find out the exact reason for this issue, but my knowledge is limited, and could not find the actual reason for this issue.

But I assume it is something that is related to the initialization of the Object from JSON.

It can be easily reproduced on a mormot server using this code. (I am trying the Example of ex\ThirdPartyDemos\martin-doyle\04-InterfacedBasedServices\src)

FYI : using Delphi 10.3 community Edition

procedure TForm1.Button1Click(Sender: TObject);
var
  sTemp : RawUtf8;
begin
 Model := TOrmModel.Create([],'root');
 HttpClient := TRestHttpClient.Create('localhost', '11111',Model,false);
 HttpClient.ServerTimestampSynchronize;
 sTemp:= HttpClient.DefinitionToJson;

 if Assigned(Model) then FreeAndNil(Model);
 if Assigned(HttpClient) then FreeAndNil(HttpClient);

 Model := TOrmModel.Create([],'root');
 httpClient:=   TRestHttpClient.CreateFromJson(Model,sTemp,false) as TRestHttpClient ;
  HttpClient.ServerTimestampSynchronize;    // ERROR at this point
 if Assigned(Model) then FreeAndNil(Model);
 if Assigned(HttpClient) then FreeAndNil(HttpClient);
End;

Thank You for pointing out and surely will follow good programming practice.  Any good link\articles\Books that you can suggest for good Delphi Programming practices that you follow.

Thank You for your time and effort.

#6 mORMot 1 » Loading & Creating from a TRestHttpClient Definition file ? » 2021-11-20 06:57:43

srp
Replies: 7

I  am trying to create a TRestHttpClient from a Json File.

However, when I run the system raises an error "Winhttp.dll Error 57". Is there something I need to initiate after loading from a file?

File test.json created using the following code
   Model := CreateSampleModel;
   HttpClient := TRestHttpClient.Create('localhost', HttpPort, Model);
   HttpClient.DefinitionToFile('c:\test.json');


Later load this using   
   Model := CreateSampleModel;
   HttpClient := TRestHttpClient(TRestHttpClient.CreateFromFile(Model,'c:\test.json',true));
   HttpClient.ServerTimestampSynchronize;  // Error  at this point.


I am using the latest version of Mormot2.


Thank You

#7 Re: mORMot 1 » How to do Custom Serialization in Mormot 2 ? » 2021-11-14 05:56:02

srp

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?

#8 Re: mORMot 1 » How to do Custom Serialization in Mormot 2 ? » 2021-11-13 15:53:38

srp

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.

#9 Re: mORMot 1 » How to do Custom Serialization in Mormot 2 ? » 2021-11-13 03:18:54

srp

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

#10 Re: mORMot 1 » How to do Custom Serialization in Mormot 2 ? » 2021-10-31 13:29:35

srp

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.

#11 mORMot 1 » How to do Custom Serialization in Mormot 2 ? » 2021-10-31 08:00:30

srp
Replies: 9

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

Board footer

Powered by FluxBB