AntonnMal / pso2-proxy

Simple proxy for PSO2NGS
MIT License
6 stars 2 forks source link

[JP] After Loged-in with Charaters, proxy will be flushing with packet S->C: 51,22 till Error 630 #3

Closed KagefumiMerry closed 7 months ago

KagefumiMerry commented 7 months ago

These S->C (0x51,0x22) packets (with some S->C: 50, 6 ) will be get when logged into NGS side, but not in Classic sides. These variable-sized packets will flushing till the client get Error 630.

I have tested that issue wont happen before code refactoring, so I need get into the code refactoring changes, especially ports and loops changes.

log.txt

I use pso2-proxy#cabf57c, pso2-protocol-lib#6c3fae2 (the latest one before code refactoring) , with minor changes, and the pso2-rsa-injector#51ded81 (ver 0.6), these combination works in harmonic.

Also, I got success to modify pso2-proxy#cabf57c to match the latest pso2-protocol-lib (ProxyConnection), so It may narrow down the issue to refactored proxy code.

AntonnMal commented 7 months ago

I cannot recreate this problem. Here are my steps: 1) I've cloned the latest commit (3b3c9bcf6c09f990da807b06405df9e03d73846d when I was testing) 2) Compiled with debug and release profiles 3) Launched the global version with Xigncode3 anticheat 4) Logged in and selected "PSO2:NGS" 5) I saw that the server was sending (0x51, 0x22) packets, (In my case the server sent 867 of those packets) 6) Successfully got into the game.

From what I see the client doesn't report back about receiving those packets.

KagefumiMerry commented 7 months ago

I think I found the issue: simply comment it out, then everything back to normal.

tokio::time::sleep(Duration::from_millis(1)).await;

https://github.com/AntonnMal/pso2-proxy/blob/0f166b0019432d78effcedfcc4f307f5779af82a/src/lib.rs#L290C9-L290C60

AntonnMal commented 7 months ago

Seems really weird; this probably needs more testing.

Note about removing that line: while sleep probably shouldn't be there, not having it is even worse because the CPU will busy-wait for other packets, which leads to unnecessarily high CPU usage.

KagefumiMerry commented 7 months ago

Not sure why the sleep weird here, in addition, any changes in duration more than 1, the proxy cause the game in to infinity loop loading and not able to reach the character menu.

Just a bit off-topic, there is an issue of that: https://github.com/tokio-rs/tokio/issues/3607

But, in fact, I could log in to the classic even there is sleep in the loop, but once change back to NGS block, this issue causing the problem.

(0x51,0x22) packets are often small, around less than 50 bytes, but sometime large up to few 10KB, before moving to Tokio::net (aka before code refactoring), it is normal here (JP), so that I may look into the detail of the asynchronous way to deal with these packets.

AntonnMal commented 7 months ago

I've done some more code refactoring to remove that sleep and make the code more async. Take a look at the async-revision branch. Maybe this will help with this issue.

KagefumiMerry commented 7 months ago

I roughly test the async-revision branch on my PC, no such issue happens again.

I thinks this issue could be considered as fixed, once this branch becomes the main one.