You are not logged in.
As far as I know, by my testings and by reading also the following reply of ab in a previous forum topic:
https://synopse.info/forum/viewtopic.php?pid=9445#p9445
error messages in interface bases services are returning to clients using exceptions. I've noticed however that this is returned to a web client not in the usual json format with ErrorCode, ErrorText properties. Instead the repsonseJSON is an object, with its textual representation given by another property, responseText as follows:
responseText: "{\r\n\"errorCode\":500,\r\n\"error\":\r\n{\"EServiceException\":{\r\n\t\"ClassName\":\"EServiceException\",\r\n\t\"Address\":\" $0000000000690839 CHANGEPASSWORD, line 36 of bareservice.pas\",\r\n\t\"Message\": \"My error message\"\r\n}}\r\n}"
Is there any way to handle errors in interface based service implementations, so to be sent back to web browsers as ErrorCode,ErrorText jsons with less severe error codes than 500?
Please let me know if the issue is gone or still exist on the latest mORMot revision when you add this line to the end of your source code.
Eugene with your modification the issue is gone, thanks a lot!
Thanks also macfly for your kind suggestion.
I've downloaded release 2.4 (thanks Eugene
) and built and run the Demo in Linux x64 with FPC 3.2.0 / Lazarus 2.0.9. When the application is shutting down (after pressing the Enter key), it raises an access violation exception at line 982 of unit mORMotHttpServer, when it attempts to execute
fDBServers[0].Server.EndCurrentThread(Sender);This happens also in Windows 10 64 bit with FPC/Lazarus but not with Delphi 10.3.
It might have something to do with the usage of IAutoFree, because using a classic try/finally approach doesn't raise any exception. ![]()
Start calls only the inherited method...
I missed one more call after the inherited Start method. This call in its simplest form (without any cache) is:
fMainRunner := TMVCRunOnRestServer.Create(Self);I tried to test a bare, hello world MVC project in FPC/linux. I created an interface, IBareApplication descendant of IMVCApplication with no extra methods and a class, TBareApplication, descendant of TMVCApplication which implements the IBareApplication. This class has only two methods Start and Default. Start calls only the inherited method and Default is empty. Then I created the Views folder with Default and Error html files, the former contains the hello world message and the latter is a modified copy from the Sample 30.
The main file creates an empty model, an in memory Rest Server and the above application:
aModel := TSQLModel.Create([],'test');
try
aServer := TSQLRestServerFullMemory.Create(aModel);
try
aApplication := TBareApplication.Create;
try
aApplication.Start(aServer);
aHTTPServer := TSQLHttpServer.Create('8092',aServer);
try
aHTTPServer.RootRedirectToURI('test/default');
aServer.RootRedirectGet := 'test/default';
writeln('Running, press ENTER to exit');
readln;
finally
...When I try to access localhost:8092/ it redirects to http://localhost:8092/test/default as expected, with a Json response contains an Error 400/Bad request message. What am I missing here? ![]()
I'm wandering if it would be possible to adapt the cross platform units (SynCrossPlatformSpecific, SynCrossPlatformREST, SynCrossPlatformCrypto) to be compatible also to pas2js. Ab do you have any hint / suggestion on what directive section to use as a basis, maybe the ISDWS? HASINLINE has to be included also?
I found a solution by passing window.location.hostname. Sorry for my rather silly question. ![]()
I modified slightly the Sample 27 - SMS cross platform client to use it in a reverse proxy nginx setup. It works only when the server address parameter of the GetClient method contains a specific address (either 127.0.0.1 or my local ip). Is there any way to pass a generic value to use the host ip address, whatever it is? I tried both the empty string and '/' without success.
By the way in the Smart Mobile Studio project, the assignment of Client to nil and the if check at the first line of the TForm1.BtnConnectClick event handler, doesn't seem to work:
if Client=nil then
...
else begin
...
Client.Free;
Client := nil;
end;A second press on the 'Server Connect' button produces nothing because the Client object hasn't become nil. A raw and clumsy solution like the following, does the work properly:
if BtnConnect.Caption='Server Connect' then
...
BtnConnect.Caption := 'Disconnect';
...
else begin
...
BtnConnect.Caption := 'Server Connect';
...
end;Following the documentation: https://synopse.info/files/html/Synopse … #TITLE_242
I added to my interface definition unit constants the following:
__TMyClient = 'Afm RawUTF8 Eponymia RawUTF8 Epaggelma RawUTF8 Diefthynsi RawUTF8 Doy RawUTF8';and in the initialization section of the same unit I added (just above the TInterfaceFactory.RegisterInterfaces call), the following line:
TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TMyClient),__TMyClient);After I recompiled the server and the client, the problem solved. ![]()
However, according to the documentation this should have already been happened by the framework itself, since the Delphi compiler creates RTTI for the record definition. Probably the FPC 3.2.0 in Linux didn't create such RTTI in the server's code. To put my 2 cents on this, when I examined the outcome of the RecordSaveJSON call in the FPC server code (before the application of the above), I got binary format. On the contrary, on the Delphi/Windows 10 client I got text JSON.
For the client (32 bit) Delphi 10.3.3 Community. For the server lazarus/fpc 64 bit on linux. I didn't register the record and I suspect that this is the cause. How do I do this? I'll take a look in the documentation.
I have a record definition like this:
TMyClient = packed record
Afm: RawUTF8;
Eponymia: RawUTF8;
Epaggelma: RawUTF8;
Diefthynsi: RawUTF8;
Doy: RawUTF8;
end;In a service interface a var parameter of this type is passed to be filled by the service:
IInvoice2Bills = interface(IInvokable)
...
function GetClientInfo(const afm: RawUTF8; var clInfo: TMyClient): integer;
...
end;When I'm attempting to call this method from a client I'm getting an EInterfaceFactoryException with message:
'TInterfacedObjectFakeClient.FakeCall(IInvoice2Bills.GetClientInfo) failed: '{
"errorCode":406,
"errorText":"IInvoice2Bills.GetClientInfo failed on clInfo:TMyClient [returned record]"
}''
In the server I can call this method without problem. Any advice is (very) appreciated.
Is it possible to draw text of different font size across columns? For example, font size 12 in the first column, font size 9 in the second and so on. DrawTextAcrossCols doesn't provide this functionality and I can't find in the documentation a function to draw text in a specific column, something like DrawTextAtCol etc.
I've just built the TestSQL3.lpi project in my old Linux Lite netbook with 2.23 libc. Thanks a lot ab and whoever else helped to solve this problem! ![]()
ab you are right. RTFM!
As it is stated here I needed the interface property to be published and not public as I had it in my initial class definition. Now I can access the injected Calculation interface directly in the method without trying to resolve it manually.
For anyone it may concern (this is a training topic
), I updated the source code of the server implementation in the gist (see the first message above).
I understand that in a case of an instance variable the resolve has to be done once, so the method is not a good place to happen. You advise me to use either the service constructor (by overriding CreateWithResolverAndRest? ), or the auto-inject feature. Can you please give me an example or a reference about the auto-inject feature usage?
Thank you both ab and Marcio for your help.
I added the line you proposed Marcio and the problem solved. This is, I suppose, the auto-inject feature ab mentioned above. It seems reasonable, although I initially found it strange, since the ICalculator service is going to be used - at least in this example - inside the server and not from a client. But from a SOA perspective, it is a sort of service usage I presume, regardless weather it is within the server context or from a client. ![]()
ab I suppose that this ICalculation service registration is mandatory for the Resolve method to work, regardless weather is going to target an instance or a local variable.
I admit that I'm a bit confused by the documentation on the topic of lazy DI. So I modified the Sample 14 to try to figure it out. Besides the ICalculator I created another interface (IMyTestService) for the actual service contract. The exposed service method is named DoTheJob. The source file is here:
https://gist.github.com/dadim/c17579859 … erface-pas
In the server implementation code (based on the In Memory Server), located here:
https://gist.github.com/dadim/c17579859 … memory-pas
I created a TMyTestService class descendant of TInjectableObjectRest which implements the IMyTestService interface. This has a private property fCalculator of ICalculator type and a public read only property (Calculator), which reads it. In the implementation code of the function DoTheJob (lines 36 - 40) I try to resolve an injection to the fCalculator property, but with no success:
function TMyTestService.DoTheJob(n1, n2: integer): integer;
begin
if Server.Services.Resolve(ICalculator, fCalculator) then
Result := fCalculator.Add(n1,n2)
end;When the client calls the DoTheJob service method, the if condition is false and the result is returned with its default, initialized value of 0. How can I inject an instance of the TServiceCalculator class to the fCalculator property?
The source code of the main form of the client (if is it of any importance), is here:
https://gist.github.com/dadim/c17579859 … ntmain-pas
Thanks a lot, ab!
Sorry for the fuss. ![]()
Thanks mpv. So, should I expect the libraries to be rebuilt with Ubuntu 16.04 and update the repository, or do I have to rebuild them myself? In the latter case, how can I do this? ![]()
In my Linux Lite old netbook is 2.23. In my OpenSUSE desktop is 2.26.
My static folder follows. File sizes are the same I think:
damian@ifestos:~/mORMot/static/x86_64-linux> ls -al
σύνολο 4824
drwxr-xr-x 2 damian users 269 Ιούν 13 12:24 .
drwxr-xr-x 15 damian users 284 Ιούν 13 12:24 ..
-rw-r--r-- 1 damian users 15328 Ιούν 13 12:24 crc32c64.o
-rw-r--r-- 1 damian users 98416 Ιούν 13 12:24 ecclin64O2.o
-rw-r--r-- 1 damian users 5272 Ιούν 13 12:24 entropy_common.o
-rw-r--r-- 1 damian users 16840 Ιούν 13 12:24 fse_compress.o
-rw-r--r-- 1 damian users 7736 Ιούν 13 12:24 fse_decompress.o
-rw-r--r-- 1 damian users 13072 Ιούν 13 12:24 huf_compress.o
-rw-r--r-- 1 damian users 37968 Ιούν 13 12:24 huf_decompress.o
-rw-r--r-- 1 damian users 3003478 Ιούν 13 12:24 libgcc.a
-rw-r--r-- 1 damian users 139656 Ιούν 13 12:24 lizard_compress.o
-rw-r--r-- 1 damian users 44880 Ιούν 13 12:24 lizard_decompress.o
-rw-r--r-- 1 damian users 16016 Ιούν 13 12:24 sha512-x64sse4.o
-rw-r--r-- 1 damian users 1512960 Ιούν 13 12:24 sqlite3.o
I repeated the problem in another Linux distro (Linux Lite, which is Ubuntu based). I can't figure out what's happening... ![]()
Please update your .o files.
I've got them from the (synced) git repo. Do I have to get them from somewhere else?
TestSQL3.lpi build fails with the following link error:
(9015) Linking /home/damian/mORMot/SQLite3/fpc/bin/x86_64-linux/TestSQL3
/usr/bin/ld: /home/damian/mORMot/./static/x86_64-linux/sqlite3.o:(.data+0x22b0): undefined reference to `fcntl64'
FPC 3.2.0 / Lazarus 2.0.9, OpenSUSE Leap 15.1
Any ideas?
The response of ab helped me to understand better the framework and more, to find the proper and simpler answer to my initial question: How to handle client to server authentication errors and get the error response. The solution is simple: Check the return value of Client.SetUser method and if false, get the error response by calling Client.LastErrorMessage. I should have known it, if I had read properly the documentation before playing with the Sample 14 code. ![]()
By the way, by assigning a procedure to the Client.OnFailed event, I also got the error response json from the Call^.OutBody property. Many thanks ab. ![]()
By taking a look at the mORMot.pas unit, line 61268 I presumed that the error json is by design embedded into the Exception Message and this was not caused by a routing misconfiguration:
...
if PosEx(SERVICE_CONTRACT_NONE_EXPECTED,ContractExpected)=0 then begin
if not InternalInvoke(SERVICE_PSEUDO_METHOD[imContract],
TSQLRestClientURI(fRest).fServicePublishOwnInterfaces,@RemoteContract,@Error) then
raise EServiceException.CreateUTF8('%.Create(): I% interface or % routing not '+
'supported by server [%]',[self,fInterfaceURI,fRest.ServicesRouting,Error]);
...So if I want to process the json error on the client side I have to extract it as a substring from the Exception error message by using something like this:
try
Client.ServiceDefine([ICalculator],sicShared);
except on E: EServiceException do
// Extract the json as a substring from inside the brackets of E.Message
end;Is there any alternative, more orthodox approach? I attempted to use a PServiceRunningContext but with no success, since at the exception point all its record properties had nil values.
I was playing with Sample 14 - Inteface based services, using named pipe (Project14Client <-> Project14Server). When I deliberately changed the username in Client.SetUser method to User1, I got an - expected - exception, although the error message contained something more than the pure error json (with errorCode, errorText properties):
TServiceFactoryClient.Create(): ICalculator interface or TSQLRestRoutingREST routing not supported by server [{
"errorCode":403,
"errorText":"Authentication Failed: Invalid signature (0)"
}].
How can I get only the error message json as the exception message? Do I have to setup the server to explicitly support TSQLRestRoutingREST routing? If so, how?
Exactly. I confirm that the problem was the absence of column size. Writing the model with index attributes as:
property GroupName: RawUTF8 index 100 read fGroupName write fGroupName stored AS_UNIQUE;
property GroupMember: variant index 1024 read fGroupMember write fGroupMember;works fine, so it was not a problem of a different sql syntax. MS SQL Server apparently supports the syntax used by the framework, as the link from w3schools posted by ab before declares.
Thanks for the hint. ![]()
I'm afraid that is not a matter of syntax. MS SQL Server doesn't support indices on nvarchar(max) at all. One (manual) workaround is to use a hashed computed column and create an index on it:
alter table Groups
alter column GroupName nvarchar(max) not null;
alter table Groups
add HashedGrN as cast(hashbytes('SHA2_256', GroupName) as varbinary(256));
alter table Groups
add constraint UC_GroupName unique(HashedGrN);The above works, but I'm not sure how efficient is it.
Unique properties as in the following example:
TSQLGroups = class(TSQLRecord)
private
fGroupName: RawUTF8;
fGroupMember: variant;
published
property GroupName: RawUTF8 read fGroupName write fGroupName stored AS_UNIQUE
property GroupMember: variant read fGroupMember write fGroupMember;
end;can't be implemented as virtual tables in MS SQL Server 2017. TSQLRestServerDB.CreateMissingTables sends the following query to SQL Server:
CREATE TABLE dbo.Groups (ID bigint NOT NULL PRIMARY KEY,GroupName nvarchar(max) NOT NULL UNIQUE,GroupMember nvarchar(max))which raises an error that the 'GroupName' column is of a type that is invalid for use as a key column in an index.
If the 'stored AS_UNIQUE' is removed from the property the Model is implemented without problem.
I ended up with a sql query as follows:
SELECT DISTINCT json_each.value
FROM Groups, json_each(GroupMember)
WHERE json_each.value LIKE 'Be%'
ORDER BY json_each.value;What is the mORMot way to formulate and execute such a query? ![]()
Thank you both. Just for the record, while in Delphi (DX) I am able to populate the directly instantiated property with Add(), in FPC I have to use a local variant variable first and assign this variable to the property in order to store correctly in the database field an array of strings. Otherwise stores an empty array.
The following lines work fine with Delphi DX, but with FPC stores in the GroupMember database field an empty array.
group := TSQLGroups.Create;
try
group.GroupName := Edit1.Text;
group.GroupMember := _Arr([]);
for i := 0 to Memo1.Lines.Count - 1 do
group.GroupMember.Add(Memo1.Lines[i]);
Database.Add(group, true);
finally
group.Free;
end;With FPC to get the same results, the code has to be changed as follows:
v := _Arr([]);
for i := 0 to Memo1.Lines.Count - 1 do
v.Add(Memo1.Lines[i]);
group := TSQLGroups.Create;
try
group.GroupName := Edit1.Text;
group.GroupMember := v;
Database.Add(group, true);
finally
group.Free;
end;Thanks. By the way, I defined the property as TStrings and mORMot created in the corresponding SQLite3 table, a field type TEXT with binary encoding. With SQLite Studio I see that in this field an array is stored with binary encoded values. When I retrieve the object using CreateAndFillPrepare, this property remains nil, where another RawUTF8 property (e.g. Name) gets its value correctly. Am I missing another step to load correctly the TStrings object from the database field into the corresponding class property?
Let's assume to have a TSQLRecord descendant class, named for example TMyDoc which have a multi valued text property, named for example Recipients. When a user creates or edits a TMyDoc object I want to enable auto completion of the Recipients property based on the existing values stored in all similar objects in the database. For example when a user writes Be the application will query all distinct Recipients values starting as this, and present a sorted list with the results, like:
Beethoven
Berlioz
What is the recommended way to implement the Recipients property in the TMyDoc class definition? As a TStrings for example? If yes, how can I perform such select distinct queries on the Recipients property?
I'm sorry for the extended code parts. ![]()
fProps is created from TSQLDBSQLite3ConnectionProperties.Create(TSQLDatabase). I understand your reservations about the direct connection but my application is very simple, with local (in-memory) connection to the database file.
For the time being, I reformat the column's text using the DBGrid OnDrawColumnCell event.
I have the following model implemented in a SQLite3 database:
TSQLSubmission = class(TSQLRecord)
private
fProtocolNumber: RawUTF8;
fSubject: RawUTF8;
fDecisionTypeId: RawUTF8;
fSubmTimestamp: TDateTime;
fStatus: RawUTF8;
fAda: RawUTF8;
fDocURL: RawUTF8;
published
property ProtocolNumber: RawUTF8 read fProtocolNumber write fProtocolNumber;
property Subject: RawUTF8 read fSubject write fSubject;
property DecisionTypeId: RawUTF8 read fDecisionTypeId write fDecisionTypeId;
property SubmTimestamp: TDateTime read fSubmTimestamp write fSubmTimestamp;
property Status: RawUTF8 read fStatus write fStatus;
property Ada: RawUTF8 read fAda write fAda;
property DocURL: RawUTF8 read fDocURL write fDocURL;
end;And I feed a VCL DBGrid with the contents of the Submission table using a TDatasource linked to a TSynSQLStatementDataSet:
var
statement: TSQLDBStatement;
sCommand: RawUTF8;
begin
if dsHistory.DataSet <> nil then
dsHistory.DataSet.Free;
sCommand := StringToUTF8('SELECT * FROM Submission');
statement := fProps.NewThreadSafeStatement;
statement.Execute(sCommand, true);
dsHistory.DataSet := ToDataSet(dsHistory, statement)
end;The SubmTimestamp DataSet Field is shown in the grid as an iso8601 UTC string and the dsHistory.DataSet.FieldByName('SubmTimestamp').DataType is ftWideString.
Any attempt to format the SubmTimestamp using one of the SQLite3 datetime functions e.g. :
sCommand := StringToUTF8('SELECT ID, ProtocolNumber, Subject, DecisionTypeId, Datetime(SubmTimestamp,''localtime'') AS SubmTimestamp, Status, Ada, DocURL FROM Submission');
statement := fProps.NewThreadSafeStatement;
statement.Execute(sCommand, true);
dsHistory.DataSet := ToDataSet(dsHistory, statement)raises the following exception when the last line of the above sample (DataSet assignment) is executed:
exception class EDatabaseError with message 'GetFieldData ColumnType=Unknown'
How can I format the SubmTimestamp in the Grid appropriately, appart from manipulating the column text using the OnDrawColumnCell event which I thing, is an overkill?
I am not able to reproduce the issue.
Strange, I've cross checked it in my computer and the result in Delphi 6 is different, as I wrote above. OS is Microsoft Windows 7 Professional 64 bits, Service Pack 1.
The following statement:
UTF8ToString(UrlEncode(StringToUTF8('https://test3.diavgeia.gov.gr/doc/Ω74ΔΡΩ2-15Δ')));in Delphi 6 produces:
https://test3.diavgeia.gov.gr/doc/%CE%A974%CE%94%CE%A1%CE%A92-15%CE%94and in Delphi XE:
https%3A%2F%2Ftest3.diavgeia.gov.gr%2Fdoc%2F%CE%A974%CE%94%CE%A1%CE%A92-15%CE%94Why? ![]()
At least for the status code, from another newbie ![]()
The status code is contained in the first line of the OutHeaders string, e.g. (XXX is the placement of the status code, DESCR is the placement of the corresponding textual description, like OK, followed by CRLF):
HTTP/1.1 XXX DESCR#13#10
The OutHeaders string is an output parameter both in HttpGet and in TWinHTTP.Post:
var
sOutHeaders, sResponse, sURL, sData, sHeaders: SockString;
...
sResponse := HttpGet(sURL, sHeaders, @sOutHeaders);
...
sResponse := TWinHTTP.Post(sURL, sData, sHeaders, true, @sOutHeaders);But I guess that for your demand, the cleanest is perhaps to write:
pdoc^.AddItem(pdoc^.Values[0]);
That was my initial thought and attempt, but it raises an EVariantBadVarTypeError exception with message 'Invalid variant type'.
Thanks a lot! I had tried this typecast:
pdoc^.AddItem(Variant(pdoc^._[0]^));but it raised a run time error with message "Invalid variant type".
After your message I used a local TDocVariantData variable, named docVData and it works! ![]()
docVData := pdoc^._[0]^;
pdoc^.AddItem(Variant(docVData));In a JSON of variable form and depth there are some properties who are arrays of objects, like "fek" in the following example:
{
...
"extraFieldValues": {
"fek": [
{
"aa": "",
"issue": "",
"issueyear": ""
}
],
...
}I have a PDocVariantData pointer pointing to "fek" and I want to add one more object in the array. However I can't use the AddItem method, because it requires a variant as parameter, so the following line produces a compilation error with message "Incompatible types: 'Variant' and 'TDocVariantData'".
pdoc^.AddItem(pdoc^._[0]^);Is there any way to typecast a TDocVariantData as a Variant and if not, how can I add to the "fek" array of the above example one more of its contained objects?
Hello,
Is there any way to generate a Form (more or less automatically from the TDocVariant or the corresponding JSON) to edit the values of a TDocVariant variable? This variable is not persisted in a TSQLRecord and it is used to communicate with an external RESTful Web Service.
Thanks
I'm a newbie in mORMot, too. I've tested your code with FPC/Lazarus in Win64 with the results you mentioned. It seems to me that during the assignment to ip2 misses somehow the data type of ip1 and due to a probably wrong typecast passes null. I modified your f2 as follows and it works:
function f2(aJO: Variant): string;
begin
aJO.ip2 := _Safe(aJO)^.U['ip1'];
aJO.ip3 := _Safe(aJO)^.U['ip1'];
result := VariantSaveJSON(aJO);
end;Just for information, I overcame the problem by calling directly TWinHTTP.Post, as follows:
procedure TForm1.Button2Click(Sender: TObject);
var
sResponse, sData, sOutHeaders: SockString;
begin
SetPostHeaders;
sData := ConstructDataString;
sResponse := TWinHTTP.Post(sURL + '/decisions', sData, sHeaders, true, @sOutHeaders);
...
end;I've just cloned the github repository, side by side with my original installation, and the problem persists.
Commit [4dd8e7cce5] not important here, as TSChannelClient.Send is not called at all.
Indeed. I applied the patch (removed len assignment after trailer and added the new len assignment before sent := 0) but the code doesn't seem to be called in this case.
By the way, the build I'm using is mORMot_and_Open_Source_friends_2019-01-23_234301_06b24ae728
If I insert some delay before first call to Recv, then I recieve 4995 bytes and handshake succeeded.
Thank you both ab and Chaa for your help and the latter's in depth analysis. Following Chaa's recommendation, I added the following in SynWinStock.pas:
ISC_REQ_FLAGS =
ISC_REQ_SEQUENCE_DETECT or ISC_REQ_REPLAY_DETECT or
ISC_REQ_CONFIDENTIALITY or ISC_REQ_EXTENDED_ERROR or
ISC_REQ_ALLOCATE_MEMORY or ISC_REQ_STREAM
// added by damian for https://synopse.info/forum/viewtopic.php?pid=28971#p28971
or ISC_REQ_USE_SUPPLIED_CREDS;and after trial and error, the following sleep call before calling HandshakeLoop in TSChannelClient.AfterConnection procedure:
sleep(40);
HandshakeLoop(aSocket);In my hardware and internet connection, sleep parameters till 30 were inadequate, but sleep(40) prevents the exception. However, this does not seem to be safe enough and infrastructure independent. If the above can lead you to any conclusion about this, you are most welcomed. ![]()
Trying to execute the following line
Http := OpenHttp('https://test3.diavgeia.gov.gr/luminapi/opendata/decisions', nil);raises the following exception:
Project test1.exe raised exception class ECrtSocket with message 'OpenBind(test3.diavgeia.gov.gr:443,open): aTLS failed [ESChannel System Error 87 [The parameter is incorrect]] [87 "The parameter is incorrect"]'. Process stopped. Use Step or Run to continue.
at line 4765 of SynCrtSock.pas:
fSecure.AfterConnection(fSock,pointer(aServer));which belongs to the procedure OpenBind:
procedure TCrtSocket.OpenBind(const aServer, aPort: SockString;
doBind: boolean; aSock: integer; aLayer: TCrtSocketLayer; aTLS: boolean);
const BINDTXT: array[boolean] of string[4] = ('open','bind');
BINDMSG: array[boolean] of string = ('Is a server running on this address:port?',
'Another process may be currently listening to this port!');
begin
fSocketLayer := aLayer;
if aSock<0 then begin
if (aPort='') and (aLayer<>cslUNIX) then
fPort := DEFAULT_PORT[aTLS] else // default port is 80/443 (HTTP/S)
fPort := aPort;
fServer := aServer;
fSock := CallServer(aServer,Port,doBind,aLayer,Timeout); // OPEN or BIND
if fSock<0 then
raise ECrtSocket.CreateFmt('OpenBind(%s:%s,%s) failed: %s',
[aServer,fPort,BINDTXT[doBind],BINDMSG[doBind]],-1);
end else
fSock := aSock; // ACCEPT mode -> socket is already created by caller
if TimeOut>0 then begin // set timout values for both directions
ReceiveTimeout := TimeOut;
SendTimeout := TimeOut;
end;
if aLayer = cslTCP then begin
TCPNoDelay := 1; // disable Nagle algorithm since we use our own buffers
KeepAlive := 1; // enable TCP keepalive (even if we rely on transport layer)
if aTLS and (aSock<0) and not doBind then
try
{$ifdef MSWINDOWS}
fSecure.AfterConnection(fSock,pointer(aServer));
{$else}
raise ECrtSocket.Create('Unsupported');
{$endif MSWINDOWS}
fTLS := true;
except
on E: Exception do
raise ECrtSocket.CreateFmt('OpenBind(%s:%s,%s): aTLS failed [%s %s]',
[aServer,Port,BINDTXT[doBind],E.ClassName,E.Message],-1);
end;
end;
end;Do you have any idea why it is happening? System is Windows 7 64-bit professional, compilers are either Delphi 6 or Lazarus 2.1.0/FPC 3.3.1. Thanks.
Hello,
I'm trying to compile sample no. 12 (SynDBExplorer) in Windows 7 64 bit, using Lazarus 2.1.0 and FPC 3.3.1. I have inserted a compiler directive to SynDBExplorerMain to use Ondrej's version of SynTaskDialog for Lazarus, as it is already used in mORMotUILogin.pas:
{$ifdef FPC}
SynTaskDialog in '..\ThirdPartyDemos\Ondrej\SynTaskDialog4Lazarus\SynTaskDialog.pas',
{$else}
SynTaskDialog, // also fix QC 37403 for Delphi 6/7/2006
{$endif}However the project does not compile, with the following errors:
Compile Project, Target: SynDBExplorer.exe: Exit code 1, Errors: 5, Hints: 1
mORMotUILogin.pas(330,33) Error: Identifier not found "SMsgDlgError"
mORMotUILogin.pas(331,33) Error: Identifier not found "SMsgDlgInformation"
mORMotUILogin.pas(668,16) Error: Identifier not found "SMsgDlgConfirm"
mORMotUILogin.pas(775,14) Error: Identifier idents no member "CreateKind"
mORMotUILogin.pas(776,14) Error: Identifier idents no member "CreateKind"
mORMotUILogin.pas(949,20) Hint: Conversion between ordinals and pointers is not portable
This is due to the absence of VCL.Consts in Lazarus. Is there any workaround? As far as I can see in the source code of mORMotUILogin.pas there are compiler directives for FPC. Have you compiled successfully this unit with FPC? Am I missing something?
Thanks.
4.4.1.3. Create variant object or array documents from JSON
In the code example, line:
V3 := _Json('{"name":?,"year":?}',[],['john',1982]);should be changed to:
V3 := _JsonFmt('{"name":?,"year":?}',[],['john',1982]);By the way, TDocVariant documents are not displayed as strings in Lazarus/FPC debugger watch. The following error is displayed in the variable watch window instead:
unsupported variant type: TFMTBcdFactory
Is there any workaround?