You are not logged in.
Pages: 1
Authentication Failed (403 – Invalid Signature) When Switching from SQLite3 to PostgreSQL
Hello,
I'm encountering an issue with mORMot when switching the backend database from SQLite3 to PostgreSQL. The application uses TRestHttpClient to connect to the server and defines services using the following pattern:
HttpClient.SetUser('MyUser', 'MyPassword');
HttpClient.ServiceDefine([IMyServiceInterface], sicShared); // Error displayed here
HttpClient.Services[IMyServiceInterface].Get(MyServiceInstance);
This setup works flawlessly when the server uses SQLite3 as its database engine. However, when I change the backend to PostgreSQL, I get the following error:
403 Forbidden: Authentication Failed - Invalid signature (0)
TServiceFactoryClient.Create(): IMyServiceInterface not supported by server
Additional Details:
The exact same code and model are used in both cases
No changes were made to the interface, service registration, or authentication logic
The user credentials are correct and worked previously
The issue appeared after switching the backend database engine only
The error appears at the ServiceDefine(...) call
What I've Checked:
PostgreSQL server is running and reachable
The schema appears correct, including the authuser table
The SetUser(...) call returns true (or was returning previously)
Everything works again if I switch back to SQLite
Please check your email; I have sent you my log
Hello everyone,
I’m working on a Delphi project using mORMot2, with a typical client-server architecture. The backend is connected to a PostgreSQL database, and the server is implemented using TRestHttpServer. On the client side, I’m using TRestHttpClient to connect to the server, perform authentication, and access the exposed service interfaces.
Up until recently, everything was functioning perfectly. The client connected to the server with no problems, authenticated successfully, and was able to execute all CRUD operations through the exposed interfaces. I didn’t make any changes to the codebase, and nothing appeared to break in deployment. Everything was solid.
However, all of a sudden, the client started throwing an exception — and consistently — when attempting to use HttpClient.Services. More specifically, the error occurs at the moment the service interface is accessed on the client side. The application throws the following:
EServiceException:
TServiceFactoryClient.Create():
Interface not supported by server
errorCode: 403
errorText: Authentication Failed: Invalid signature (0)
This is particularly confusing because, as I mentioned, no code was changed between the working state and this new behavior. The server is still running, the database connection is alive and well, and the client is connecting to the same endpoint using the same authentication credentials as before. The SetUser call is still in place with the same login details, and I’ve verified that the
model and interface declarations between the client and server are identical.
The exception occurs specifically when the client attempts to access a service interface through:
HttpClient.ServiceDefine([IMyServiceInterface],sicShared)
This was previously working without error. Now, it consistently fails at this point, returning a 403 with an invalid signature message, suggesting that some internal mismatch or signature validation is now failing where it wasn’t before
Hello ,
I'm following the PDF tutorial but encountering some issues:
1-Additional Tutorials: Are there any other tutorials available for SynProject beyond the PDF documentation?
2File Not Found Errors: When I try to set up my project, I get "File Not Found" errors for Delphi library files like:
system.str
mormot.core.base (is i need to incule mormot path also)
variant.pas
....
I'm working on Windows. Could you please advise:
Do I need to manually specify paths to all used libraries?
Is there a standard setup procedure I might be missing?
Any common solutions for these missing file errors?
Hello,
I have a `Start` and `Stop` function for my server. In the `Start` function, I initialize some data in the database by calling multiple initialization functions like:
initSomething1(varRest: IRestOrm);
{
varRest.orm.add()
}
initSomething2(varRest: IRestOrm);
{
varRest.orm.add()
}
Each of these functions works with `varRest: IRestOrm` to initialize data.
In the `Stop` function, I free my `TRestHttpServer` and `TRestServerDb` variables as follows:
procedure TDeamon.Stop;
begin
TSynLog.Enter(self);
DbContext.Destroy;
restHttpServer.Free;
restServerDb.Free;
end;
To avoid reference count issues, I explicitly set `varRest := nil` in each `initSomething()` function. However, I still encounter the same exception when stopping the server:
! EXC ERestException {Message : "TINYRestServerDb.destroy : TRestOrmServerDb.RefCount = 201"}
any insights on what could still be holding references to `IRestOrm`?
Hello everybody , I am encountering an issue when stopping my server, which is built using mORMot2. When I close the server, I get the following exception:
! EXC ERestException {Message : "TMYRestServerDb.destroy : TRestOrmServerDb.RefCount = 201"} [Main] at 68ad63
@AB Bypassing the ORM and using direct SQL queries can indeed lead to creating new connections in PostgreSQL each time a query is executed. This can result in a large number of connections being opened unnecessarily, which may overwhelm the database
@itSDS Limiting connections in PostgreSQL during high traffic can indeed be challenging. If we have 1,000 users and limit connections to 900, it could create a bottleneck, leaving some users unable to access the database
Thank you for your response! I understand that reducing the number of threads in my HTTP server can help manage database connections more efficiently. However, my application will be handling many simultaneous requests from a large number of users.
Would reducing the number of threads negatively impact performance in such a scenario? If so, is there a recommended way to balance the number of threads while ensuring efficient database connection usage?
Hello everyone,
I’m facing an issue when executing custom SQL queries using methods like `.Execute()`or `.ExecuteJSon()`. Every time I run a custom query, a new connection is created to the database, which is causing performance issues and overwhelming the database (postgress) with too many open connections.
- I need to execute custom SQL queries (e.g., complex `SELECT` statements with `JOIN`, `WHERE`, etc...) that cannot be easily expressed using the standard ORM methods
- When I use `Execute`or `ExecuteJSON`, a new connection is created each time, which is not efficient.
- This results in too many open connections, impacting performance and potentially hitting the database's connection limit.
Example of My Query:
there're more complexe queries than this one :
function TNSAServ.FetchOrderDetails(ACustomerID: RawUtf8): RawUtf8;
var
Query: RawUtf8;
begin
Query := FormatUtf8(
'SELECT o.OrderID, o.OrderDate, c.CustomerName, p.ProductName, p.Price ' +
'FROM Orders o ' +
'JOIN Customers c ON c.CustomerID = o.CustomerID ' +
'JOIN Products p ON p.ProductID = o.ProductID ' +
'WHERE o.CustomerID = % ' +
'ORDER BY o.OrderDate DESC',
[ACustomerID]);
// Execute the query and return the result as JSON
Result := fServer.ExecuteJson([], Query );
end;
In this example, the query retrieves order details for a specific customer by joining three tables (`Orders`, `Customers`, and `Products`). However, each call to `ExecuteJson` creates a new connection, which is not optimal.
I am trying to find a way to get record values and store them in docVariantData without using serialization/deserialization ?
Hello everyone,
I am encountering an issue when attempting to use RTTI (Run-Time Type Information) in Delphi to convert a record into a dynamic TDocVariantData. My goal is to loop through all fields or properties of a record and dynamically build a variant structure.
function RecordToDocVariant<T>(const ARecord: T): Variant;
var
Ctx: TRttiContext;
Typ: TRttiType;
Prop: TRttiProperty;
begin
Result := TDocVariantData.New;
Ctx := TRttiContext.Create;
try
Typ := Ctx.GetType(TypeInfo(T)); // Retrieve RTTI for type T
if Typ = nil then
raise Exception.Create('RTTI not available for the type');
for Prop in Typ.GetProperties do
begin
Result.AddValue(Prop.Name, Prop.GetValue(@ARecord).AsVariant);
end;
finally
Ctx.Free;
end;
end;
Example Call
Here’s how I’m calling the function:
var
MyRecord: TMyRecord;
DocVariant: Variant;
begin
MyRecord.ID := 123;
MyRecord.Code := 'ABC123';
DocVariant := RecordToDocVariant<TMyRecord>(MyRecord);
WriteLn(DocVariant.ID);
WriteLn(DocVariant.Code);
end;
Is it a feature that is available to use in my Mormot2 application?
example :
TMyClass = class(TOrm)
private
[Default(42)]
FMyProperty: Integer;
public
property MyProperty: Integer read FMyProperty write FMyProperty;
end;
.
@flydev thank You
zen010101 , link doesn't work
I've been banging my head against the wall for the past few hours trying to get TRestHttpServer working with HTTPS. Every time I try to start the server, it fails with this error:
! OSERR mormot.rest.http.server.TRestHttpServer(035F7860) http.sys URI registration error #183 for https://+:xxxx/root
! EXC ERestHttpServer {Message:"TRestHttpServer: http.sys URI registration error #183 for https://+:xxxx/root"}
Here's what I'm trying to do:
MyServer.HttpServer := TRestHttpServer.Create(
xxxxx,
[MyServer],
'+',
HTTP_DEFAULT_MODE,
16,
secTLSSelfSigned
);
I'm running the app as admin, and I've tried different ports and using '*' instead of '+' for the binding address, but no luck. The weird thing is that it works fine if I remove the HTTPS stuff, but I really need secure communication for this project.
I've looked through the documentation and searched the forum, but I can't figure out what I'm missing. Is there some special setup needed for HTTP.sys when using self-signed certificates? Or am I doing something completely wrong with the TRestHttpServer creation?
I’m facing a problem where TOrmTableDataSet3 is read-only, preventing me from modifying the dataset.
I'm loading the dataset using TOrmTableDataSet.CreateFromJson. Here's the code I’m using for appending data:
UniEdit1.onkeyPress
with DataSource1.DataSet do
begin
Append;
FieldByName('NewQty').AsString := 'AG-' + Format('%', [UniEdit1.Text]);
end;
However, I keep getting the error => TOrmTableDataSet3: Cannot modify a read-only dataset.
So, every time in the implementation, I need to do a case statement for each class like this:
case ClassType of
User: DoSomething;
Product: DoSomethingElse;
...
ClassNumber15: DoAnotherThing;
...
end;
Is there a way to check which class is in the parameter and process it directly without having to check all cases one by one?
How can I create a function in a service that contains a parameter var aClass: TOrmClass and use it in a test unit? When I try to implement this, I encounter an access violation error. Could you please advise on the correct approach or what might be causing the issue?
function
Pages: 1