You are not logged in.
Compiling error at:
[dcc32 Error] mormot.net.sock.pas(1353): E2441 Inline function declared in interface section must not use local symbol 'PSockAddr'
Delphi 11
Indeed, I was mixing those pieces of information. Thanks!
Thanks for the suggestion about the best protocol in my case.
However, I can't test that point because I am stuck on try connecting to the server. I can't test the rest of my code because I can't go on from the connection phase. I tried different WebSockets servers and the result was always the same ('Is a server available on this address:port? THttpClientWebSockets.OpenBind({websocket site}) [Not Found - #3]'):
var ClientWS : THttpClientWebSockets;
WSSConnection : TGetWSSRequests;
lProto : TWebSocketProtocolChat;
begin
WSSConnection := TGetWSSRequests.Create;
ClientWS := THttpClientWebSockets.Create;
ClientWS.OnCallbackRequestProcess := WSSConnection.DealWSSRequests;
ClientWS.Open('wss://socketsbay.com/wss/v2/2/demo','443'); // <--- HERE it raises the error I told in my first message
...I don't need a REST WebSocket in my case, and that's why I am using 'THttpClientWebSockets'. Unfortunately, while I tried looking through the mORMot 2 source code and samples, I didn't find the right way to work with 'THttpClientWebSockets' so far. I thought it was like 'TSimpleHttpClient' with the particularities of 'WebSockets', eg. the callback functions. All samples that I saw about this matter were using both server and client using mORMmot. I didn't see a sample for using WebSockets to talk to an ordinary WebSocket server.
Hello,
I have seen some mORMot samples showing up how to create both server and client using WebSocket, using different protocols. I created a simple client to communicate with an ordinary WebSocket server, and when I try using a 'THttpClientWebSockets' to access it when I do a 'Client.Open(WSS site, port)' I receive a 'Is a server available on this address:port? THttpClientWebSockets.OpenBind({websocket site}) [Not Found - #3]' error message. The WebSocket site is working ok, and I've tested it using one WebSocket tester website, like 'https://www.piesocket.com/websocket-tester', receiving the expected initial message.
Can an ordinary WebSocket server be accessed through mORMot using 'THttpClientWebSockets'? I tested both '80' and '443' ports that I guess are the ones to access the WebSocket server that I need because the above WebSocket tester even needs a port in the URI for accessing the server. In case that is possible, the best protocol to be used would be 'TWebSocketProtocolJson'? The server uses plain JSON to receive commands and send responses.
Thanks for any help!
When I tried recompiling a code using the latest mORMot 2 source code I got the following error:
[dcc32 Error] mormot.core.buffers.pas(2228): E2169 Field definition not allowed after methods or properties
Delphi 11
It is because your code is incorrect.
The JSON is an object holding an array, not an array itself.
Ok, thanks!
Hi Thomas and Arnaud!
I can confirm that. I am using Delphi 10.3.3. 'DynArrayLoadJson' didn't work in this case. The fix shown by Thomas worked as expected, but why was it necessary to create a 'packed record' type of the array of the fields loaded from the JSON, and not the array type itself? I didn't see that need when I read the item '10.1.3.2.4 Text-based definition' of mORMot's documentation.
Thank you!
Hi there,
While learning more about mORMot2 I am doing some tests with JSON. I am loading a JSON and trying to deserialize it with 'DynArrayLoadJson'. You can check it here https://github.com/PrometeusRec/mormot_ … n/Test.pas
The JSON file test is there as well. However, no 'JSON' is being loaded into the array. My questions are:
1) Is the JSON content different from what 'DynArrayLoadJson' expects, or is there some error in the type of the fields?
2) On that sample 'packed record' created there is a commented field that is not present in the JSON that I need to read (the exact type shown in the '.TXT' file). The original 'JSON' file may have more fields than the 'packed record' that you will need, but the contrary is not allowed? I would like to make some processing and save the results in fields of the same 'packed record'. Is that possible?
Thanks!
No, the default authentication has a specific signature computed for each URI.
Check the documentation about it.What you can do is use a JWT instead.
Thank you for the prompt answer. I think you are talking about my second question when I try to access the REST API using authentication, but my current test (using SSL) is not using authentication (I did it without SSL and it worked according to documentation), so the signature computed for a URI should not be used in this case, right? What is the cause of the "Authentication Failed: Invalid signature (0)" message?
No, speed is same, I say it's easier to maintain. I've started too with SQLModel for existing FB that's used outside of my app and I've transitioned to interface based approach, following sqlmodel proved too restrictive especially since I need data from several tables.
The applications use the FB database, and now it will be accessed by a mobile application as well. I am really impressed with SQLite 3 performance, and I thought about converting the FB database to it, but I am concerned about SQLite issues with simultaneous writing. I don't know SQLite well, but I am aware of its limitation when dealing with concurrency writings, so I will stick with an external database for while.
I already followed Mormot documentation about SSL, and I am trying to test it using Chrome or Firefox. Despite Chrome not liking my "Dev Certification Authority" and showing it as "Not Secure" (For Firefox it is ok), I am doing simple tests using a browser, and after that build the client-side. After the SLL all set, I am trying accessing the REST API with SSL enabled (the source above was updated):
'https://localhost:8043/root/test/1'
and I am receiving:
{
"errorCode":403,
"errorText":"Authentication Failed: Invalid signature (0)"
}
Googling a little, I found that this message is related to a problem in authenticating. However, I am setting 'aHandleUserAuthentication' to 'false', at first. 'AUTHGROUP' and 'AUTHUSER' tables were created by Mormot when I was testing authenticating without SSL (I guess that they are only used if 'aHandleUserAuthentication' is set to 'true', right?), but I want to have the REST API accessing working with SSL without authentication first, then with it.
After fixing this issue (accessing the REST API through a browser or AJAX client) can the right above input using authentication like this?
'https://localhost:8043/root/test/1?user=User&password=synopse'
Thank you AB, I'll take a look at it!
So you have some existing Firebird DB and you want to serve data from it though REST server?
Note that in such case I would skip altogether defining TSQLModel with existing tables and using FB as external DB. Write interface service that would connect to database (with zeos for example), get data as json and return it to client.
Thank you for the suggestion. I already got my application test working as expected and using the 'standard' way with TSQLModel. I have included in my tests Mormot secure authentication and it worked too, and now I am trying to have it working with SSL. Is there a real advantage for using interface services, like more speed in the JSON response, for instance? I still didn't study this part of Mormot documentation, but anyway I am already glad about the results that I am getting. Mormot framework is the most impressive piece of code for Delphi in this area that I have seen, and I wonder why I didn't hear about it before.
The test table already exists. I created a fresh Firebird database with just one table and two fields only to begin to understand and learn the Mormot framework. I was expecting that the "CreateMissingTables" call create the 'ID' field on that table. However, that is not happening and, according to the error posted, "CreateMissingTables" is trying to read that field, when the error occurs.
Hello,
I begin using the Mormot framework and my primary interest in it is as a REST server. I read some docs about how to do for Mormot to access external databases (Firebird in this case), including the Mormot manual related, and I created a small test, but it is raising an error when I call 'CreateMissingTables'. The code and the error message generated are at https://gist.github.com/PrometeusRec/c4 … 68732fbd9f
I am using the latest 'Zeos' version and compiling for Delphi 10.3.3
I am trying to fix this basic thing for two days, but I can't understand what is wrong with it. The 'TEST.FDB' database has just two raws but looks like the 'ID' field is not being really created in the 'CreateMissingTables' call, but it thinks that it was, and then the error message raised. Am I missing something for this test work?
Thanks for any help.