You are not logged in.
Hello, I'm struggling for a while now with an exception:
ECrtSocket ("SockRecvLn 10060 WSAETIMEDOUT [A connection attempt failed because the connected party did not properly respond after a period of time,
or established connection failed because connected host has failed to respond]")
This error only occurs when the server is called from a Chrome browser (Edge is ok).
When I use the THttpApiServer class the error does not occur either.
There is no difference on running the server on windows 10 or linux (using delphi 7 or crossKylix)
The problem is narrowed down to the following code:
program Test;
uses
{$I SynDprUses.inc}
SynCommons, SynCrtSock, SynLog;
{$APPTYPE CONSOLE}
type
TTestServer = class
private
fServer: THttpServerGeneric;
public
constructor Create;
destructor Destroy; override;
function onRequest(Ctxt: THttpServerRequest): cardinal;
end;
constructor TTestServer.Create;
begin
fServer := THttpServer.Create('8888', nil, nil, '');
// fServer := THttpApiServer.Create(false);
// THttpApiServer(fServer).AddUrl('','8888', False, 'localhost');
fServer.OnRequest := onRequest;
with TSynLog.Family do
begin
Level := LOG_VERBOSE;
EchoToConsole := LOG_VERBOSE;
PerThreadLog := ptIdentifiedInOnFile;
end;
end;
destructor TTestServer.Destroy;
begin
fServer.Free;
inherited;
end;
function TTestServer.onRequest(Ctxt: THttpServerRequest): cardinal;
begin
Writeln('Hello!');
Ctxt.OutContentType := HTML_CONTENT_TYPE;
Ctxt.OutContent := 'Hello!';
Result := 200;
end;
var
LServer: TTestServer;
begin
LServer := TTestServer.Create;
Writeln('Server localhost:8888');
Readln;
LServer.Free;
end.
In this sample the server keeps running.
But in the server application I've created which uses TWebSocketServer and runs in a Docker container on Linux, the application stops working after a while with several exceptions.
Further our Angular client application takes a few seconds to start (after the WSAETIMEDOUT error is reported).
I hope this explains the problem sufficiently.
Help would be much appreciated.
Last edited by Wytze (2018-03-08 11:30:13)
Offline
Are you using the latest revision of the framework?
Current is 1.18.4400.
We did a lot of fixes in the socket-based server.
Under Linux, it is expected to run this server on the loopback, behind a nginx front-end (for DoS and https).
Offline
Thanks for the quick reply,
I've just updated from 1.18.4363 to 1.18.4402.
Saw some interesting changes, which might help the Linux application stability.
However also: [CrossKylix] DEBUG: C:/Dev/struct/mORMot/SynCrtSock.pas(11002) Error: Constant expression violates subrange bounds.
The corresponding code: curl.Module := -1; // don't try to load any more
Code is introduced in 1.18.4397.
The 'WSAETIMEDOUT' error on Windows 10 is still there.
Last edited by Wytze (2018-03-08 15:33:33)
Offline
I've fixed the Kylix problem via https://synopse.info/fossil/info/41ea0d4330
But I am not able to reproduce your WSAETIMEDOUT on Windows 10 + Chrome.
Also note that using writeln() is never a good idea in a multi-threaded server application.
Offline
Great, the linux build is working again and hasn't broken yet.
Removed the WriteLn in the 'onRequest' function (was no need for that).
Concerning the 'WSAETIMEDOUT' error reproduction, maybe I must add that there is no reverseproxy running inbetween.
When I run e.g. Fiddler the error does not occur.
Offline
I'm facing the same exception on windows 10 whith last mormot, compiled with delph 10.3.:
ECrtSocket ("SockRecvLn [10060 WSAETIMEDOUT
When opening any web browser calling a server defined as useBidirSocket, for example:
HttpServer := TSQLHttpServer.Create('8080',[ServerDB],'+',useBidirSocket);
If I open it from a client aplication or define it "HttpServer := TSQLHttpServer.Create('8080', [ServerDB])" it works ok.
Am I doing anything wrong or mising something?
Any Clue?
Thanks in advance.
Offline
I am not able to reproduce it.
Sounds like a URI registration / Firewal issue to me.
Do the regression tests (TestSQL3.dpr) run as expected on you machine?
Could you try sample "04 - HTTP Client-Server" and check if it works as expected?
Offline
My fault, after doin the tests you mention, I realiced that the exception was catched and only shows in debug or vervose_log. (data was returned ok even in the browser)
Maybe is the normal behabiour, just a little weird that only appears when accessing from web browser.
I write done the test you said anyway:
sample "04 - HTTP Client-Server" with client and server exe run ok, accessing via web browser shows security:
{
"errorCode":403,
"errorText":"Authentication Failed: Invalid signature (0)"
}
The regresion test failed till I disabled kaspersky antivirus, but the problem with the exception remains after disabling kaspersky even after disabling windows firewall.
Windows 10 64bit (10.0.15063) (cp1252)
2 x Intel(R) Core(TM) i7-6820EQ CPU @ 2.80GHz (x86)
Using mORMot 1.18.5334
TSQLite3LibraryStatic 3.29.0 with internal MM
Generated with: Delphi 10.3 Rio 32 bit compiler
Time elapsed for all tests: 2m32
Performed 2019-09-17 11:23:28 by admin on WIN10-POR104
Total assertions failed for all test suits: 0 / 41,844,695
! All tests passed successfully.
I've also tryed to set timeout and call to WebSocketsEnable like sample 31:
TWebSocketServerRest(HttpServer).ServerKeepAliveTimeOut := 3000;
{ WebSocketServerRest := } HttpServer.WebSocketsEnable(ServerDB, '', False, False);
Offline
I guess the problem is that you main run the server in the IDE debugger, or your computer doesn't have enough computing power.
The Delphi debugger is not able to handle multiple threads in a proper manner, so I have seen some queries abort with a timeout error message, e.g. when running TestSQL3 regression tests.
Running a server in the Delphi debugger may not work as expected, especially if you are pausing the debugging session - other threads are also suspended.
I guess the firewall is not the problem here.
But your AntiVirus is most probably intercepting the socket connection on the loopback, taking a lot of CPU.
2 cores (I guess in your VM) may not be enough with Kaspersky enabled. I personnally use Nod32, putting TestSQL3.exe in the exception list.
Offline