Hercules icon indicating copy to clipboard operation
Hercules copied to clipboard

Fix server sync reading and wrong disconnection from API Server

Open guilherme-gm opened this issue 1 year ago • 1 comments

CAREFUL! UNTESTED CODE AHEAD

I have not done any thoroughly testing/validation of this code. I am opening this as a draft in case people who are experiencing the issue wants to check / try. I can not guarantee this won't cause any unexpected side effects at this time.

Pull Request Prelude

Changes Proposed

This fixes how packet 0x272D (CharServer -> LoginServer online accounts sync) is read by Login Server. Thus, preventing accounts from being wrongly marked as offline.

When login-server marks an account as offline, it will eventually tell API Server to disconnect them, thus also invalidating users' API Tokens while they are in game.

Huge thanks to AcidMarco in Herc's discord that provided a quite good explanation of what he has observed and this helped me a lot in finding the root cause (or at least I think it did...)

I am still having a hard time believing this is the fix, because this code has been untouched for almost 10 years, but I will perform a deeper investigation when I have some time (and before making this PR ready to review)

Issues addressed: None, I think.

guilherme-gm avatar Jul 01 '24 01:07 guilherme-gm

Probably unrelated to this PR, but there's one more issue wherein API server is called for autotraders on restart, and we get bunch of Account not online errors

dastgirp avatar Jul 01 '24 11:07 dastgirp

Probably unrelated to this PR, but there's one more issue wherein API server is called for autotraders on restart, and we get bunch of Account not online errors

Yeah, I think this is a separate issue. I will take a look into it and open a new PR if I find something (maybe we should create an issue about it?)

guilherme-gm avatar Jul 28 '24 15:07 guilherme-gm

Hello, I applied this on my server and it fixes some of recent problem but after few hours of server being online the character-login gets disconnected.

I don't know how it happen or reproduce its just gets disconnected. Then i had to restart the Login and Character server to be able to login again.

image

@dastgirp , @guilherme-gm any updates?

vBrenth avatar Aug 09 '24 17:08 vBrenth

@vBrenth can you try using the first commit only? this one: https://github.com/HerculesWS/Hercules/pull/3304/commits/29d858c70589fdb8a3279d930103a43b8cc7d6c7

I am wondering if I may have made a mistake when converting to struct.

guilherme-gm avatar Aug 10 '24 14:08 guilherme-gm

@guilherme-gm I've been running the first commit only and its still having some saving problem but less and no disconnection between char and login so far.

vBrenth avatar Aug 12 '24 04:08 vBrenth

@guilherme-gm I've been running the first commit only and its still having some saving problem but less and no disconnection between char and login so far.

Thanks for the update, I made a fix on #3312 so the 2nd commit properly works.

Are the saving problems giving any logs? is there any reproduction steps for it? I think we need to figure out whether this is a server issue or a client one, since I noticed that there are some cases where the client doesn't send the changes to be saved

guilherme-gm avatar Aug 18 '24 19:08 guilherme-gm

I cant find a way to reproduce it. Its just happen after some time with players are online.

vBrenth avatar Aug 18 '24 19:08 vBrenth