You are not logged in.
Situation
===
I compiled the '04 - HTTP Client-Server' official mORMot sample and have successfully deployed it on a Windows 2016 server behind IIS 10, the server has both http/80 and https/443 ports open, and both are redirected to the background mORMot rest server using the IIS URL Rewrite module.
The IIS-as-the-reverse-proxy part is already working, because I was able to connect to the remote mORMot server using:
TSQLHttpClient.Create('server.mysite.com','80', Form1.Model);
The https part is also working, because open 'https://server.mysite.com/root' with a web browser I can get the correct result from Project04Server.exe, which is:
{
"errorCode": 403,
"errorText": "Authentication Failed: Invalid signature (0)"
}
The problem
===
The problem is that Project04Client.exe cannot connect to the remote Project04Server.exe, I have tried all the following forms but failed with various errors:
Form1.Database := TSQLHttpClient.Create('server.mysite.com','80', Form1.Model); // ok, but not https
Form1.Database := TSQLHttpClient.Create('server.mysite.com','443',Form1.Model); // failed, ServerTimestampSynchronize will fail
Form1.Database := TSQLHttpClient.Create('https://server.mysite.com','443',Form1.Model); // failed, ServerTimestampSynchronize will fail
Form1.Database := TSQLHttpClient.Create('https://server.mysite.com','80',Form1.Model); // failed, ServerTimestampSynchronize will fail
Form1.Database := TSQLHttpsClient.Create('https://server.mysite.com', Form1.Model, 443); // failed, ServerTimestampSynchronize will fail
Form1.Database := TSQLHttpClientWinINet.Create('https://server.mysite.com', Form1.Model, 443); // failed, ServerTimestampSynchronize will fail
myUri.From('https://server.mysite.com');
Form1.Database := NewSQLHttpClient(myUri, Form1.Model, False); // Access Violation
Form1.Database := TSQLHttpClientRequest(TSQLHttpsClient).Create('server.mysite.com', '443',
Form1.Model, True); // Access Violation
What is the correct way to connect a https-enabled mORMot rest server?
Thanks!
Last edited by edwinsn (2018-04-15 11:10:38)
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
OK, right after posting the question, I found the answer:
Form1.Database := TSQLHttpClientWinHTTP.Create('server.mysite.com','443', Form1.Model, True); // ok! it's httpS!
Hope it helps for somebody else
But I guess the global NewSQLHttpClient function still has the Access Violation issue.
Last edited by edwinsn (2018-04-15 11:05:57)
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
But I guess the global NewSQLHttpClient function still has the Access Violation issue.
I think you are right. I guess I found a mistype in NewSQLHttpClient function. There we have:
result := TSQLHttpClientRequest(TSQLHttpsClient).Create(aURI.Server, aURI.Port, aModel,
aURI.Https, AnsiString(aProxyName), AnsiString(aProxyByPass));
I suppose, that there is some tiny mess with the brackets
The correct code should be:
result := TSQLHttpClientRequest(TSQLHttpsClient.Create(aURI.Server, aURI.Port, aModel,
aURI.Https, AnsiString(aProxyName), AnsiString(aProxyByPass)));
upd: I've created a pull request for that
Last edited by Vitaly (2019-03-21 15:37:15)
Offline
I don't think so.
We test for TSQLHttpsClient.InheritsFrom(TSQLHttpClientRequest) before it, and use the correct meta-class constructor if it supports it.
For instance, on Android, TSQLHttpsClient = TSQLHttpClientWinSock and your modification won't compile.
Offline
Well, maybe you are right - I'm not so experienced in such constructions.
But, anyway, in Delphi VCL the function works fine with the suggested code, and the original function fails with AV in inherited TSQLRest.Create(aModel: TSQLModel) constructor
I'm not insisting on updating your code I've already created the copy of function and using it in my project - just worried about others, who can face the same problem
Last edited by Vitaly (2019-03-21 15:57:18)
Offline
After more investigation, there was in fact a problem, mainly due to the non uniformity of the class constructors: TSQLHttpClientRequest did have another set of parameters.
So I get rid of the NewSQLHttpClient() function, and a simple constructor is to be used instead, for any kind of class.
See https://synopse.info/fossil/info/5008dfb3fc
You can now directly use TSQLHttpsClient.Create() on all platforms.
Offline