#1 2024-04-09 16:33:35

imperyal
Member
Registered: 2018-10-11
Posts: 54

Error on SockSendFlush

I frequently have this error, only on debug (Delphi 12).

Error:
Project xpto.exe raised exception class ENetSock with message 'THttpClientSocket.SockSendFlush(127.0.0.1) len=292 [Fatal Error - #6]'

It doesn't happen every time and not in the same place (in the code)... It appears to be harmless.

Offline

#2 2024-04-09 17:14:57

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Error on SockSendFlush

Maybe there is a timeout in debug mode?

Is the server in the same process?

Offline

#3 2024-04-09 17:58:32

imperyal
Member
Registered: 2018-10-11
Posts: 54

Re: Error on SockSendFlush

No, the server is a separate program altogether.

I can add the Call Stack if that helps...

Offline

#4 2024-04-09 18:07:08

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Error on SockSendFlush

Perhaps https://github.com/synopse/mORMot2/commit/598c16d2 could help to include the low-level Win32 API error code.

Offline

#5 2024-04-10 10:57:11

imperyal
Member
Registered: 2018-10-11
Posts: 54

Re: Error on SockSendFlush

Hello,

Using the commit above I get:

Error_01.png

Error_02.png

Error_03.png


If I open and close the app rapidly I get no error... Seems to be time dependent, but I could be wong.

Last edited by imperyal (2024-04-10 10:59:06)

Offline

#6 2024-04-10 13:49:21

imperyal
Member
Registered: 2018-10-11
Posts: 54

Re: Error on SockSendFlush

When my app is not doing nothing I still get those errors, it could confirm this time dependent theory.

Erro and Call Stack:

Error_04a.png

Error_04b.png

Offline

#7 2024-04-10 16:39:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Error on SockSendFlush

OK now I understand.
sys=10054  means WSAECONNRESET.

My guess is that the connection is just closed by the server after a while, and you have the background thread which "_ping_" the server on this closed connection.
It raises an exception, which is caught as expected, then a new client connection is created, and the "_ping_" succeeds.

On production, you don't see this exception, because it is caught/intercepted, then a new connection is made.
In debug mode, you see this exception, but the client continues to work as expected.

The server-side timeout is set by TAuthGroup.SessionTimeout. Usually it is 60 minutes for a non-admin user, so the "_ping_" is done every 30 minutes (half the session timeout value).
If you don't like this "hearbeat / ping" feature, just set TRestClientUri.SessionHeartbeatSeconds := 0.
Also ensure you did not make a too small value in the TAuthGroup.SessionTimeout of the user's group.

Offline

#8 2024-04-10 17:11:26

imperyal
Member
Registered: 2018-10-11
Posts: 54

Re: Error on SockSendFlush

Yes, on production there is no error.

Our TAuthGroup.SessionTimeout is 60.

But I get those errors after way less the 30 minutes of inactivity...

In this next case, only 7 minutes have passed:

Error_05.png


I think there is something else going on...

Last edited by imperyal (2024-04-10 17:12:19)

Offline

#9 2024-04-10 19:39:41

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Error on SockSendFlush

Which class are you using on the server side?

This may be the KeepAlive paramter on server side.

Offline

#10 2024-04-11 08:44:03

imperyal
Member
Registered: 2018-10-11
Posts: 54

Re: Error on SockSendFlush

I'm using the TRestHttpServer class to expose a TRestServerDB server (more precisely, a class that extends the TRestServerDB with some server methods, and some helper methods as well.. nothing too fancy).

Offline

#11 2024-04-11 09:19:30

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Error on SockSendFlush

TRestHttpServer with which kind of HTTP server? async? socket?

Perhaps https://github.com/synopse/mORMot2/commit/e8293e77 would help.
It should detect any broken connection before sending the request, then re-create the connection, and therefore avoid any exception.

Offline

#12 2024-04-11 10:47:56

imperyal
Member
Registered: 2018-10-11
Posts: 54

Re: Error on SockSendFlush

I'm just creating it like that:

MSS_ServerDB.DB.Synchronous := smOff;
MSS_ServerDB.DB.LockingMode := lmExclusive;

TRestHttpServer.Create(K_conn_port_cloud, [MSS_ServerDB], '+', useHttpApiRegisteringURI, 32, secSSL,  '', '')

If that's not the best way to create the server please advise...

Last edited by imperyal (2024-04-11 10:51:07)

Offline

#13 2024-04-11 11:36:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Error on SockSendFlush

So you are using the http.sys Windows server (useHttpApiRegisteringURI).
I don't know why it reset the connection after 7 minutes. My guess is that it should not. But it could do whatever it wants, and it is a Microsoft-owned system blackbox.

Anyway, please try my latest commit above: it should avoid any exception on the client side, which should gracefully reconnect in such cases.

Offline

#14 2024-04-11 13:57:03

imperyal
Member
Registered: 2018-10-11
Posts: 54

Re: Error on SockSendFlush

I will try that commit and let you know.
It is a small annoying thing (it disrupts the debug a little) but it does not affect anything as far as I'm aware.

Side note: on mORMot 1 that didn't happen. Same server configuration (useHttpApiRegisteringURI).

Offline

#15 2024-04-12 12:25:06

imperyal
Member
Registered: 2018-10-11
Posts: 54

Re: Error on SockSendFlush

The problem is solved, no more errors while debugging.

Is it safe to use this commit (e8293e7) in production?

Thank you once again Arnaud

Offline

#16 2024-04-12 13:54:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Error on SockSendFlush

I have fixed some client-related issues this morning.

You should perhaps better use
https://github.com/synopse/mORMot2/commit/509c8565

Offline

#17 2024-04-12 15:15:04

imperyal
Member
Registered: 2018-10-11
Posts: 54

Re: Error on SockSendFlush

Ok, thank you!

Offline

Board footer

Powered by FluxBB