#1 2018-09-09 12:38:46

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Is SessionClose the opposite of SetUser?

So I have been implementing the "Login" operation via TSQLRestClientURI.SetUser, but recently I noticed the server-side logs contains log messages something like "ECrtSocket (... connection closed forcibly by remote host...) " when a client program exits, so I thought maybe the program needs to do a "Logout" via SessionClose, **Is it correct?** If not, what method implements the "logout" operation Thanks.

Last edited by edwinsn (2018-09-09 12:39:15)


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2018-09-10 10:44:39

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Is SessionClose the opposite of SetUser?

When you free the client it will automatically call SessionClose.

SessionClose is the correct way to "logout"

Offline

#3 2018-09-10 14:00:17

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Is SessionClose the opposite of SetUser?

@pvn0,

Thanks for the help. The program does free the client in the main form's Destroy destructor method, but the server-side
still produce the mentioned ECrtSocket error log.

And I noticed a strange phenomenon - when I run the program in debug mode and step into the TSQLRestClientURI.Destroy source code, no more ECrtSocket exception log, as if the program needs to close **slowly**, strange...


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2018-09-12 11:04:04

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Is SessionClose the opposite of SetUser?

I can't tell what is wrong just by your description, try to recreate the problem in a brand new test project and then post the code here so we can replicate.

Offline

#5 2018-10-08 10:53:30

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Is SessionClose the opposite of SetUser?

Have you resolved your issue? I have only seen this error if Client calls SessionClose (manually or through destructor) while a session releated operation is still active on the server so this is by design.

Offline

#6 2018-10-08 18:00:10

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Is SessionClose the opposite of SetUser?

No, I've not been able to fix the issue yet, but since the issue is not severe so it is of low priority here, but I'll be appreciated if anybody give me a pointer smile


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#7 2018-10-09 03:42:54

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Is SessionClose the opposite of SetUser?

pvn0 wrote:

...I have only seen this error if Client calls SessionClose (manually or through destructor) while a session releated operation is still active on the server...

How do I know 'a session releated operation is still active on the server'? Your hint is helpful, Thanks!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#8 2018-10-09 06:11:50

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Is SessionClose the opposite of SetUser?

Original log entry (the words between ... and ... were translated from my local language):

EXC       ECrtSocket ("SockRecvLn [10054 WSAECONNRESET \"... connection closed forcibly by remote host...\"]") at 0096414A SynCrtSock.TCrtSocket.SockRecvLn (5153)  stack trace API

Using the latest mORMot as of today.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#9 2018-10-09 07:23:43

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Is SessionClose the opposite of SetUser?

edwinsn wrote:

How do I know 'a session releated operation is still active on the server'? Your hint is helpful, Thanks!


Original log entry (the words between ... and ... were translated from my local language):

EXC       ECrtSocket ("SockRecvLn [10054 WSAECONNRESET \"... connection closed forcibly by remote host...\"]") at 0096414A SynCrtSock.TCrtSocket.SockRecvLn (5153)  stack trace API

Using the latest mORMot as of today.


I only ever see this error when I'm debugging server side, and while I'm debugging, the client calls sessionclose (because I closed the client so destructor is triggered).

Here's what windows docs have to say :

WSAECONNRESET 10054 Connection reset by peer.

An existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO_LINGER option on the remote socket). This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress. Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.

So for me, this is all works as expected, I hope this helps you pinpoint the problem in your code.

Last edited by pvn0 (2018-10-09 07:26:23)

Offline

#10 2018-10-10 16:40:59

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Is SessionClose the opposite of SetUser?

@pvn0, thank you! The info you provided is helpful for me to further understand the issue, however, at my side the solution is still not obvious, so I'll postpone the check.  But i'll post updates when I find some details.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB