You are not logged in.
Pages: 1
One step further, I located the creation of the handles in function procedure SynOleDB.TOleDBConnection.Connect;
// open the connection to the DB
OleDBCheck(fDBInitialize.Initialize);
I assume the connection is not closed before destroying the connection. I will look further on it.
Hi ab,
please do you have any idea where I have to look for an solution? It seems te be something in the Connection.Execute functie.
Thanks!
O, excuse me. I use the TOleDBMSSQL2008ConnectionProperties db connector.
It is created in the CreateDBConnection function.
Or is it better to have one global db connection and use it from all threads?
regards!
Hello,
I am nearer to the source of this problem:
function TUploader.CheckIP: Boolean;
var
ip, ident: String;
con: TOleDBMSSQL2008ConnectionProperties;
function do_check(con: TOleDBMSSQL2008ConnectionProperties): Boolean;
var
ips: ISQLDBRows;
begin
Result := False;
if not assigned(con) then
Exit;
ips := con.Execute('SELECT identifier FROM AllowedSenders WHERE IP=?',[ip]);
while ips.Step do
begin
if VarToStrDef(ips['identifier'],'') = ident then
begin
Result := True;
Exit;
end;
end;
end;
begin
Result := False;
ip := FindIniNameValue(pointer(ServiceContext.Request.Call.InHead),'REMOTEIP: ');
if ip = '' then
Exit;
ident := GetURLParam('Identifier');
if ident = '' then
Exit;
con := dtmlConfig.CreateDBConnection;
try
Result := do_check(con);
finally
con.Free;
end;
end;
When I use this code, it leaves me with 3 windows Handles. Problem is in function do_check().
Hello,
it seems there is a Windows handle leak in mormot server. For every call to my service there are 5 handles added in my app (empty test service function).
So after running for some hours, or after heavy testing with SoapUI, there are access violations at unexpected places in my app.
I check the handle count with this function:
function GetProcessHandleCount(const hProcess: DWORD;
var pdwHandleCount: DWORD): BOOL; stdcall; external 'kernel32.dll';
Is this a known problem and how can I solve it? Could the build in caching the source of this problem?
I use rest server in sicSingle mode.
thanks for your reply,
Thanks for your reply. The built in authentication cannot be used since the server is accessed from external Ajax enabled web app.
So I found a way which works for me now, I override the TSQLHttpServer object to TMySQLHttpServer and then override the Request function to TMySQLHttpServer.Request.
I added extra checks to that overridden Request function to only allow calling my TUploader service.
It is not a very nice solution, but that way I can do it without modifications to the mormot source.
When I inspect the retrieved TSQL... record without flushing cache before, some properties are empty (although there is data in database for that record), other are filled with correct values.
Hi,
the reason to enable this option is to prevent viewing the dataset from normal browser session.
The main reason we use mormot at this moment is to do advanced processing in services added to the rest server. If possible I would also prevent showing the tables content (CRUD) via REST, to have only the custom services published, but not my table contents. Is that possible? We have build an advanced uploader API based on a service:
FRESTServer.ServiceRegister(TUploader,[TypeInfo(IUploader)],sicSingle);
The best practice for this application should have only this TUploader service published, but not my table contents.
regards!
I found the problem. My customer's web app is sending multiple content types. So it seems it is better to change the Request function a little:
function TSQLHttpServer.Request(Ctxt: THttpServerRequest): cardinal;
var call: TSQLRestURIParams;
i: integer;
P: PUTF8Char;
begin
if (Ctxt.URL='') or (Ctxt.Method='') or
(OnlyJSONRequests and
not ContainsUTF8(pointer(Ctxt.InContentType),'APPLICATION/JSON')) then //IdemPChar -> ContainsUTF8 to check for matching part of content type
begin
// wrong Input parameters or not JSON request: 400 BAD REQUEST
result := HTML_BADREQUEST end else
Hello,
when I do this settings:
HTTPServer.OnlyJSONRequests := True
FHTTPServer.AccessControlAllowed := '*'
The AccessControlAllowed does not work any more, from AJAX it is not possible to get the info. We get an error: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://oursite.nl' is therefore not allowed access.
When I set OnlyJSONRequests to False, it works OK.
Is there anybody who knows more about this behaviour?
Sorry, how do I get that?
ServiceContext.Factory.RestServer.Cache.?
Thanks!
I use the 1.18 from 3 weeks ago.
TSQLUploads = class(TSQLRecord)
private
FUploadsID: Integer;
FOrderlineID: RawUTF8;
FLongID: RawUTF8;
FOrderXML: RawUTF8;
FQuantity: Integer;
FAssigned: Integer;
FCreated: TCreateTime;
FUpdated: TModTime;
FUpdateCount: Integer;
FJoinList: TSQLJoinTest;
FUploadsPath: String;
FChiliWorkspaceID: String;
FChiliViewPreferencesID: String;
FChiliConstraintsID: String;
FChiliFoldingSettingsID: String;
FUIUploadAllowed: Integer;
FUIShow3D: Integer;
FChiliClipartFolderName: String;
FUIShowPositionList: Integer;
FUIShowRotation: Integer;
FUIShowMirroring: Integer;
FUIAllowPositionNetto: Integer;
FUIAllowPositionBruto: Integer;
FUIAllowPositionImageSize: Integer;
FUIAllowPositionOneCmWhite: Integer;
FChiliIsGeneralTemplate: Integer;
function AS_UNIQUE(const Index: Integer): Boolean;
published
property OrderlineID: RawUTF8 read FOrderlineID write FOrderlineID;
property Quantity: Integer read FQuantity write FQuantity;
property LongID: RawUTF8 index 50 read FLongID write FLongID stored AS_UNIQUE;
property OrderXML: RawUTF8 read FOrderXML write FOrderXML;
property Assigned: Integer read FAssigned write FAssigned;
property Created: TCreateTime read FCreated;
property Updated: TModTime read FUpdated;
property UpdateCount: Integer read FUpdateCount write FUpdateCount;
property JoinList: TSQLJoinTest read FJoinList;
property UploadsPath: String read FUploadsPath;
property ChiliIsGeneralTemplate: Integer read FChiliIsGeneralTemplate write FChiliIsGeneralTemplate;
property ChiliWorkspaceID: String read FChiliWorkspaceID write FChiliWorkspaceID;
property ChiliViewPreferencesID: String read FChiliViewPreferencesID write FChiliViewPreferencesID;
property ChiliConstraintsID: String read FChiliConstraintsID write FChiliConstraintsID;
property ChiliFoldingSettingsID: String read FChiliFoldingSettingsID write FChiliFoldingSettingsID;
property ChiliClipartFolderName: String read FChiliClipartFolderName write FChiliClipartFolderName;
property UIUploadAllowed: Integer read FUIUploadAllowed write FUIUploadAllowed;
property UIShow3D: Integer read FUIShow3D write FUIShow3D;
property UIShowPositionList: Integer read FUIShowPositionList write FUIShowPositionList;
property UIShowMirroring: Integer read FUIShowMirroring write FUIShowMirroring;
property UIShowRotation: Integer read FUIShowRotation write FUIShowRotation;
property UIAllowPositionImageSize: Integer read FUIAllowPositionImageSize write FUIAllowPositionImageSize;
property UIAllowPositionBruto: Integer read FUIAllowPositionBruto write FUIAllowPositionBruto;
property UIAllowPositionNetto: Integer read FUIAllowPositionNetto write FUIAllowPositionNetto;
property UIAllowPositionOneCmWhite: Integer read FUIAllowPositionOneCmWhite write FUIAllowPositionOneCmWhite;
end;
I think I got a solution: When I do a ServiceContext.Factory.RestServer.Cache.Flush; the data seems to be correct.
But it keeps strange, because I do not UPDATE this table via direct SQL functions.
So any extra input to understand the mechanism is welcome!
Hello,
I am using Mormot for some weeks now and I am running into problems with my data.
I have some services added to rest server. Within a service I add a new record to database:
ServiceContext.Factory.RestServer.Add(rec);
where rec is my TSQLRecord based data record.
This will always save the info to database as expected.
After that I do a retrieve (in other service call):
ServiceContext.Factory.RestServer.Retrieve(rec_id, rec);
Here it goes wrong. Some fields (not all) are empty, where my database manager tells me the record contains data!
After changing some properties I update the database record with:
ServiceContext.Factory.RestServer.Update(rec_id, rec);
At this point the empty fields will be written to database and overwrite the existing data.
I am using MS SQL Server 2008 Express.
At Global level I defined:
function TdtmlConfig.GetDBConnection: TOleDBMSSQL2008ConnectionProperties;
begin
if not Assigned(FDBConfig) then
FDBConfig := TOleDBMSSQL2008ConnectionProperties.Create(FDatabaseServer,FDatabaseName, FDatabaseUser, FDatabasePassword);
Result := FDBConfig;
end;
When creating the model:
FModel := TSQLModel.Create([TSQLUploads, TSQLDocuments, TSQLDocumentPages, TSQLAssets, TSQLJoinTest, TSQLTimeline],ROOT_NAME);
VirtualTableExternalRegisterAll(FModel, dtmlConfig.GetDBConnection, True);
When I get data from database with the same GetDBConnection.Execute, it gives all fields with values. So the dataconnection seems good. It must have to be something in the restserver retrieve function.
Could it be some caching problems?
Thanks for help!
Pages: 1