You are not logged in.
Pages: 1
Hi there. I've just build a simple Http web service while learning Mormot.
Everything is working well but connection time (measured using ARC -- Advanced Rest Client Application) seems very slow (a little more than 1 second) when usually should be less than 10 ms
My server is defined like this:
TMyHttpServer = class
private
FModel: TSQLModel;
FRestServer: TSQLRestServer;
FHttpServer: TSQLHttpServer;
public
constructor Create(AProps: TSQLDBConnectionProperties; const APort: RawUTF8);
destructor Destroy; override;
end;
TMyRestServer = class(TSQLRestServerFullMemory)
private
FProps: TSQLDBConnectionProperties;
public
constructor Create(AModel: TSQLModel; AProps: TSQLDBConnectionProperties); reintroduce; overload;
published
procedure SomeResource(Ctxt: TSQLRestServerURIContext);
end;
And implemented this way:
constructor TMyHttpServer.Create(AProps: TSQLDBConnectionProperties; const APort: RawUTF8);
const
ROOT_PATH = 'root';
HTTP_OPTN: TSQLHttpServerOptions = UseHttpApiRegisteringURI;
begin
inherited Create;
with TSQLLog.Family do
begin
Level := [sllNone];
PerThreadLog := ptIdentifiedInOnFile;
end;
FModel := TSQLModel.Create([], ROOT_PATH);
FRestServer := TMyRestServer.Create(FModel, AProps);
FHttpServer := TSQLHttpServer.Create(APort, [FRestServer], '+', HTTP_OPTN);
FHttpServer.AccessControlAllowOrigin := '*';
end;
constructor TMyRestServer.Create(AModel: TSQLModel; AProps: TSQLDBConnectionProperties);
begin
inherited Create(AModel, False);
FProps := AProps;
end;
And here is the console app code:
var
FProps: TSQLDBConnectionProperties;
FConnection: TSQLDBConnection;
begin
FProps := FunctionToCreateDBConnectionProps.Create('DB_PATH', 'DB_USER', 'DB_PASS');
try
FConnection := FProps.ThreadSafeConnection;
if not FConnection.Connected then
FConnection.Connect;
with TMyHttpServer.Create(FProps, HTTP_PORT) do
try
Readln;
finally
Free;
end;
finally
FProps.Free;
end;
end.
Any hints ?
Offline
Never mind. I was missing run 1 time as 'Administrator' to http.sys registration stuff.
Regards,
Offline
Pages: 1