You are not logged in.
Pages: 1
Thank you, AB
It's my mistake. In the method, I used codes。
Orm.ExecuteJson([], fsSQL,true, @fTotal );
The reason for this error is that fTotal requires int64, but I put it in integer.
Also shared with everyone.
Only a few interface methods runs wrong. And , the same interface methods were compiled and run normally under the original Win10 and CodeTyphon 8.1.
The system environment is Linux64, fpcdeluxe lazarus 3.99, The latest framework version .
In my interface method, I used try.. Except end structure, no exception was caught. At the end of the method, be able to log the correct SQL and return the rawjson value. But in HTTP calls, the result cannot be returned normally, instead it is a 500 error.
and EAccessViolation (dcbd5f40) [R1:orp] at 4327f0 orpDaemon.lpr (535) ../../src/core/mormot.core.interfaces.pas (6948) is asm.
20240808 15472828 $ - 00.173.691
20240808 15472846 ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=1 free=0 client=0
20240808 15472915 ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=1 free=0 client=0
20240808 15472946 ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=1 free=0 client=0
20240808 15473015 ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=0 free=1 client=0
20240808 15473161 $ + mormot.rest.sqlite3.TRestServerDB(7fdee549b550).URI GET orp/ORP.listresPlan?aFields=ORPPlan&aresID=1557&aWhere=&session_signature=00085cbe0030f50dc8c151c4 in=0 B
20240808 15473161 $ call mormot.rest.sqlite3.TRestServerDB(7fdee549b550) ORP.listresPlan["ORPPlan",1557,"",false]
20240808 15473210 $ SQL mormot.rest.sqlite3.TRestServerDB(7fdee549b550) 182.20ms returned 4 rows as 1.9 KB select a.* ,resID from orpPlan a left outer JOIN (select PID,ResID FROM ORPPlanSource where resID = 1557 ) b on b.PID=a.ID
20240808 15473210 $ res mormot.db.raw.sqlite3.TSqlDatabase(7fdee5522a80) [{"ID":1,"typeCode":"","GUID":"","PID":"",... (truncated) length=1950
20240808 15473210 $ +
20240808 15473210 $ info [{"ID":1,"typeCode":"","GUID":"","PID":"",...] //result log , correct
20240808 15473210 $ - 00.000.004
20240808 15473210 $ EXCOS EAccessViolation (dcbd5f40) [R1:orp] at 4327f0 orpDaemon.lpr (535) ../../src/core/mormot.core.interfaces.pas (6948)
20240808 15473210 $ debug mormot.rest.sqlite3.TRestServerDB(7fdee549b550) TRestServerRoutingRest.Error: { "errorCode":500, "error": {"EAccessViolation": { "ClassName": "EAccessViolation", "Address": "7fdedcbd6400", "Message": "Access violation" }} }
20240808 15473210 $ srvr Interface GET orp/ORP.listresPlan=500 out=157 B in 182.55ms
20240808 15473210 $ ret mormot.rest.server.TRestServerRoutingRest(7fdedd052530) { "errorCode":500, "error": {"EAccessViolation": { "ClassName": "EAccessViolation", "Address": "7fdedcbd6400", "Message": "Access violation" }} }
20240808 15473210 $ - 00.182.581
20240808 15473215 ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=1 free=0 client=0
20240808 15473246 ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=1 free=0 client=0
20240808 15473315 ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=1 free=0 client=0
20240808 15473346 ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=0 free=1 client=0
Thank you! Of course, if there are events, use events, if there are interfaces, use interfaces, and callback functions are also acceptable.
In order to improve system security and project reliability, a user audit function is added to record user behavior logs. One method is to use TSynLog, another method is to intercept method events from the interface, and finally the framework's time machine.
I hope everyone can help improve the plan and provide key suggestions.
thanks
I have a front-end application for Vue3, which uses methods for static files and interfaces for data. Two servers are publicly available online through a TRestHttpServer. Using a browser, this application works very well. In order to process a large amount of data, I developed a Lazarus client and implemented this feature through an interface. The problem is that if the server is placed behind NGINX using the HTTPS protocol, my client cannot connect to the server. What should I do?
Behind NGINX in the HTTPS protocol, there is our TRestHttpServer in the HTTP protocol. How can our TRestHttpClient connect to this server? What protocol does the client use?
en,I have same trouble。and it take me afew day try to read forum and change my code。
//Server.RootRedirectToUri('/static/web/'); //old code ,
Server.RootRedirectToUri('/static/web');
server.Route.Get('/static/web','/static/web/index.html',urmGet);
server.Route.get('/static/assets/*','/static/web/assets/*',urmGet);
Thanks help!!!
Now , I have install a IDE of Lazarus in aarch64 Linux.
I try some sample in ex. And the httpServerRaw is passed . It can runing in aarch64 linux os. Other servers are say "error while linking".
In the new stable version, I found that there are static files with the aarch64 Linux directory. Does this support cross compiling to this situation in the new version?
I attempted to compile under CodeTyphon under Win64 and encountered an error while linking. Master, can you tell me the relevant solutions?
follow the res file
stripped
ServiceRunningContext^.Factory.ORM; can do some CRUD
When I called an interface service in a long running thread on the server, an error occurred. Some objects are not initialized
I define a function named fDB; And It done.
function FDB: TRestServer;
begin
fDB:=ServiceRunningContext^.Request.Server;
end;
使用接口建立服务,我设计了一个TInterfacedObjectWithCustomCreate为基类的ImplementationClass。现在,我有两个不同root的DB,aDB,bDB.分别注册了这个ImplementationClass。在ImplementationClass的方法里,我怎么分别这是运行在aDB或者是bDB?或者说,我在方法的运行期间,怎么样获取它注册的工厂类和TRESTSERVERDB
Using an interface to create a service, I designed an ImplementationClass with TInterfacedObjectWithCustomCreate as the base class. Now, I have two different root DBs, aDB and bDB. Each has registered this ImplementationClass. In the ImplementationClass method, how can I distinguish whether this is running on aDB or bDB? In other words, how do I obtain the registered factory class and TRESTSERVERDB of a method during its operation
Today I found a problem. In the JS client, after logging in to the server, execute the remote service to get the data. When we use F12 to debug the browsing page, the URL of the last data retrieval will be displayed in the network tag. If I copy this URL, I can open it in other browsers or computers and get data. Is this a disguised way to skip security verification? After I log out, the above URL will no longer be valid. I wonder if there are properties on the server side that can be used for time comparison between two ends? Or The session_signature can only be used once on the server side? My usage environment is window, M2
http://127.0.0.1:19217/orp/orp_FTS.whereQuery?aTypeTable=orp_rs_dzwj&aWhere=%20where%20NianDu%3D%221989%22&aPage=1&aPageLine=30&session_signature=000f52f8001d8f15d8a3c4db
I down the new release mORMot 2.0.4099 . and it is ok! thanks !
I am working on M2.0.3780 , FPC
I have same sample. I think that javascript client can't login out. and It shall down by time out only.
<code>
20220928 14503721 call mormot.rest.sqlite3.TRestServerDB(0a049570) Auth UserName=xxx&Session=733137&session_signature=000b2fd10082dc93c261c1d9
20220928 14503721 debug mormot.rest.sqlite3.TRestServerDB(0a049570) TRestServerRoutingRest.Error: { "errorCode":400, "errorText":"Bad Request" }
</code>
Are there new version by M2?
Guys, I want to add a scheduled service method to the rest server. This method mainly completes the functions of statistics, backup, synchronization, etc. These functions need to call the interface methods on the server. I hope to get some advice.
I find the way . It can run.
aFileStream:rawUtf8;
FFileStream:= Base64ToBin(aFileStream);
I found base-64 encoded strings in server's log.
20220715 06444743 call mormot.rest.sqlite3.TRestServerDB(01742b20) ITypeAction.upLoadFile{"aTypeCode":"pdf","aTypeID":0,"aFilename":"pdf0.pdf","aFileStream":"JVBERi0xLjcNCiWhs8XXDQo3IDAgb2JqDQo8PC9UeXB ............
20220715 06444743 debug mormot.rest.sqlite3.TRestServerDB(01742b20) TRestServerRoutingRest.Error: { "errorCode":406, "errorText":"ITypeAction.upLoadFile failed parsing aFileStream: RawByteString from input JSON" }
20220715 06444743 srvr xxx POST orp/TypeAction.upLoadFile Interface=406 out=120 B in 4.29ms
but it can run to my code in upLoadFile function.
I have same error . I have interface service it work ok when use V1.18. and I turn to V2 ,It can't work . Something is different?
function upLoadFile(aTypeCode: rawUtf8; aTypeID: Integer;
aFilename: rawUtf8; aFileStream: RawByteString; fileDate: TDateTime;
aLoginID: Integer): Integer;
AJAX:
reader.readAsDataURL(file)
reader.onload = (fd) => {
let fdd = fd.target.result.substring(fd.target.result.indexOf(',') + 1); // read from file by
axios({
method: "POST",
url: '/TypeAction.upLoadFile',
headers : {'Content-Type': 'multipart/form-data'} ,
contentType: "application/json;charset=utf-8",
data:{
aTypeCode :'pdf',
aTypeID : 0,
aFilename:'pdf0.pdf',
aFileStream: fdd,
fileDate: Date(),
aLoginID: 9
},
timeout: 8000
}).then()......
The error info:
20220715 01495607 debug mormot.rest.sqlite3.TRestServerDB(04e07b20) TRestServerRoutingRest.Error: { "errorCode":406, "errorText":"ITypeAction.upLoadFile failed parsing aFileStream: RawByteString from input JSON" }
I got the answer. Thanks!
https://synopse.info/forum/viewtopic.php?id=5241
You need to provide more info, compiled with Delphi? Which version? Both client and server using same compiler & build mode? Modern Delphi string type is UnicodeString by default UTF-16 encoded so as expected uses more space then UTF-8 encoded rawutf8.
I use codetyphon 7.6 ,fpc 3.3.1, windows 7 64bit.
In server side ,I add to interface object.
TORP_FTSObject =class(TInterfacedObject, Iorp_FTS)
function fullToHalf(aStr:rawutf8):rawutf8;
end;
Hi, Master!
I have some strings code Different in client and server 。I want change some UTF8char(CJK) to ansichar. In client it do ok, and the length of strings is 285. but in server it make Garbled code, and the length of strings is 190。
Can I get any suggest?
function fullToHalf(aStr: rawutf8): rawutf8;
var
str0,str1,str2:strings;
strcnw:strings;
Flags: TReplaceFlags;
n,iCount:Integer;
const
strcn:string='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ‘1234567890-=\~!#$%^&()_+|〔〕{};’:,。/<>?【】“”';
stren:string='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=\~!#$%^&()_+|[]{};'':,./<>?[]""';
begin
try
strcnw:=utf8String(strcn);
str0:=astr;
with tsynlog.Enter() do
begin
log(sllinfo,str0);
log(sllinfo,inttostr(length(strcn))+' char'); //190 or 285
log(sllinfo,inttostr(length(strcnw))+' wchar'); //190 or 285
log(sllinfo,inttostr(length(stren))+' echar'); //95
end;
for n:=1 to 93 do
begin
str1:=copy(strcnw,n*2-1,2); // copy(strcnw,n*3-2,3);
str2:=copy(stren,n,1);
Flags:=[rfReplaceAll];
str0:=StringReplace(str0,str1,str2,iCount);
if iCount>0 then
begin
with tsynlog.Enter() do
begin
log(sllinfo,str1+' '+str2 +' '+inttostr(iCount));
//log(sllinfo,);
end;
end;
end;
Result:=str0;
with tsynlog.Enter() do
begin
log(sllinfo,' result: ');
log(sllinfo,Result);
end;
except
on E:exception do
begin
with tsynlog.Enter() do
begin
log(sllinfo,' half error: '+E.Message);
end;
end;
end;
end;
You need to allow custom tokenizer by call to EnableCustomTokenizer, and when execute a statement SELECT fts3_tokenizer during just after connecting to database
Hi,mpv!
Can you share a Complete example ?
someone show me a sample with a lots of details?
in the AuthUser table , data created by CreateMissingTables .
Admin , Supervisor , User , same PasswordHashHexa=67aeea294e1cb515236fd7829c55ec820ef888e8e221814d24d83b3dc4d825dd
Hi,every one!
I see "salt" in password encryption. I want to find an easy way to provide different "salt" to generate different passwords. Prevent the password of "user" from overriding the password of "admin" to obtain permission. So what should I do?
thinks !
How to save a File to MongoDB with mORMot Framework?
I Use TMongoClient to link MongoDB like sample in Documentation. But the Sample don't tell me how to save a Pictrue , file or stream to MongoDB.
Could You tell how to do? and get it back.
----------------------------------------------
here is the Sample.
---------------------------------------------
var Coll: TMongoCollection;
doc: variant;
i: integer;
begin
Coll := DB.CollectionOrCreate[COLL_NAME];
TDocVariant.New(doc);
for i := 1 to 10 do
begin
doc.Clear;
doc.Name := 'Name '+IntToStr(i+1);
doc.Number := i;
Coll.Save(doc);
writeln('Inserted with _id=',doc._id);
end;
end;
-----------------------------
http://synopse.info/files/html/Synopse% … #TITLE_187
Pages: 1