Grasscutters / Grasscutter

A server software reimplementation for a certain anime game.
https://grasscutter.io/
GNU Affero General Public License v3.0
16.18k stars 4.47k forks source link

Server keep looping "Conv inconsistency" #341

Closed TheOrdinaryWow closed 2 years ago

TheOrdinaryWow commented 2 years ago

Server: Latest dev branch, all set up. Running on a remote server, and client uses iOS device.

Issue: After running the server and I entered the game for a short while, server started to loop the following errors:


[02:18:08] [INFO] Client disconnected from $IP_ADDRESS
[02:18:10] [INFO] Client connected from $IP_ADDRESS
java.io.IOException: Conv inconsistency
at io.jpower.kcp.netty.Ukcp.input(Ukcp.java:147)
at io.jpower.kcp.netty.UkcpServerChildChannel.kcpInput(UkcpServerChildChannel.java:201)
at io.jpower.kcp.netty.UkcpServerChannel$UkcpServerUnsafe.read(UkcpServerChannel.java:591)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)

_* $IPADDRESS reserved for privacy.

On discord support channel I was told that someone faced this problem before, but only in the situation that server has high ping. The server ping to my device real-time is around 100ms, which I guess not "too high".

Also I've checked issue #73, but it seems that we are facing the different problem. What described in that issue was that the server only bring up spam only when restarting the server, while on my side it spams few seconds I entered the game.

This caused me loop in the first CG, and it infos "reconnecting network" after the CG ends, then replay again.

I've checked my device and excluded all possible client-side factors, hence I believe this is a server-side bug.

It'd be nice if you could please have a glance of this issue. Thanks.

lhhxxxxx commented 2 years ago

maybe you should clear the database

ClayCoffee commented 2 years ago

maybe you should clear the database

It works, but i am afraid it's a bug

lhhxxxxx commented 2 years ago

也许你应该清除数据库

它有效,但我担心这是一个错误

This should indeed be a bug, it always appears after using the giveall command. There seems to be some conflict in the database

lhhxxxxx commented 2 years ago

And something strange happened, when I used giveall (enough backpack capacity), "112046 - Famed Handguard - 名刀镡" did not appear in the backpack, but when I used the give command again to give the same amount, the backpack appeared double, so obviously the items given the first time may not be displayed (and not consumed) for some reason

lhhxxxxx commented 2 years ago

11111.png it seems that it wasn't added to the database

TheOrdinaryWow commented 2 years ago

maybe you should clear the database

Okay I'll try, but one thing worth mentioning is that I didn't even start playing the game, so theoretically there should not be any data in the database perhaps.

On my side I'm still stuck at the first CG, choosing the character's one.

alt3ri commented 2 years ago

Try to wipe entire database>?

lhhxxxxx commented 2 years ago

Try to wipe entire database>?

it works, but after using the giveall command, it turns back to this situation

TheOrdinaryWow commented 2 years ago

Try to wipe entire database>?

it works, but after using the giveall command, it turns back to this situation

I'm not familiar with MongoDB, but here's what I did after I shutdown the jar:

root in remote-server in ~
❯ mongo
......
> show dbs;
admin        0.000GB
config       0.000GB
grasscutter  0.000GB
local        0.000GB
> use grasscutter;
switched to db grasscutter
> db.dropDatabase();
{ "ok" : 1 }
> exit
bye

And I started the server and ran on my device but problem stills.

CK-Tex commented 2 years ago

This issue happens as long as I run giveall

TheOrdinaryWow commented 2 years ago

Update:

Problem still. And this seems more likely to be a client-side issue of those who use proxy clients instead of setting the HTTP proxy in system settings. Using a proxy client(eg. Surge, Shadowrocket or any that supports DNS Rewrite and MitM) to handle MitM works fine, as tested. But it seems that it's not able to handle kcp traffic as server required. This is perhaps a bug, but I'm not sure. I can provide the proxy app's config file if requested.

4Benj commented 2 years ago

Potentially related: #399

TheOrdinaryWow commented 2 years ago

Potentially related: #399

Perhaps, but on my side the server didn't respond 502, or any kind of error or even warning.

4Benj commented 2 years ago

Perhaps, but on my side the server didn't respond 502, or any kind of error or even warning.

This issue has existed since GC was made public and as far as I know this happens when the session gets closed for one reason or another and potentially when the client has trouble staying connected to the server, and the client hasn't realised it has been disconnected hence the spam of "conv inconsistency" basically the client trying to brute force a connection until it eventually gives up and just logs in again.

I'm hoping to work on a fix for the error spam some time soon so the client gets notified that it has been disconnected but I wouldn't get your hopes up if it's the client struggling to stay connected...

TheOrdinaryWow commented 2 years ago

Perhaps, but on my side the server didn't respond 502, or any kind of error or even warning.

This issue has existed since GC was made public and as far as I know this happens when the session gets closed for one reason or another and potentially when the client has trouble staying connected to the server, and the client hasn't realised it has been disconnected hence the spam of "conv inconsistency" basically the client trying to brute force a connection until it eventually gives up and just logs in again.

I'm hoping to work on a fix for the error spam some time soon so the client gets notified that it has been disconnected but I wouldn't get your hopes up if it's the client struggling to stay connected...

Sincerely thanks for your support. I have recognized that this is a client-side issue, but I just wonder the reason for it. I use the proxy app 24*7 due to personal situation, yet I have never met any kind of issue like this, even in game. So this problem seems quite rare to me. What makes me want to believe that this is a server-side issue is that I tried different proxy apps since I thought it was the client-side issue, thus switching to another one might work, yet it did not make any difference. And hence, I believe it’s a rare situation on specific situation. It might be able to be fixed on server-side, otherwise there’s no way other games I proxied didn’t crash.

Extra Content

if anyone wanted to give it a shot with my method, you could try this, take Shadowrocket for example. Create a new conf, edit plain text, and add following codes:

[Host]
api-os-takumi.mihoyo.com = $SERVER_PublicIP
hk4e-api-os-static.mihoyo.com = $SERVER_PublicIP
hk4e-sdk-os.mihoyo.com = $SERVER_PublicIP
dispatchosglobal.yuanshen.com = $SERVER_PublicIP
osusadispatch.yuanshen.com = $SERVER_PublicIP
account.mihoyo.com = $SERVER_PublicIP
log-upload-os.mihoyo.com = $SERVER_PublicIP
dispatchcntest.yuanshen.com = $SERVER_PublicIP
devlog-upload.mihoyo.com = $SERVER_PublicIP
webstatic.mihoyo.com = $SERVER_PublicIP
log-upload.mihoyo.com = $SERVER_PublicIP
hk4e-sdk.mihoyo.com = $SERVER_PublicIP
api-beta-sdk.mihoyo.com = $SERVER_PublicIP
api-beta-sdk-os.mihoyo.com = $SERVER_PublicIP
cnbeta01dispatch.yuanshen.com = $SERVER_PublicIP
dispatchcnglobal.yuanshen.com = $SERVER_PublicIP
cnbeta02dispatch.yuanshen.com = $SERVER_PublicIP
sdk-os-static.mihoyo.com = $SERVER_PublicIP
webstatic-sea.mihoyo.com = $SERVER_PublicIP
hk4e-sdk-os-static.hoyoverse.com = $SERVER_PublicIP
webstatic-sea.hoyoverse.com = $SERVER_PublicIP
sdk-os-static.hoyoverse.com = $SERVER_PublicIP
api-account-os.hoyoverse.com = $SERVER_PublicIP
hk4e-sdk-os.hoyoverse.com = $SERVER_PublicIP
overseauspider.yuanshen.com = $SERVER_PublicIP
gameapi-account.mihoyo.com = $SERVER_PublicIP
minor-api.mihoyo.com = $SERVER_PublicIP
hk4e-sdk-os.hoyoverse.com = $SERVER_PublicIP
uspider.yuanshen.com = $SERVER_PublicIP
sdk-static.mihoyo.com = $SERVER_PublicIP

[URL Rewrite]
hk4e-api-os-static.mihoyo.com $SERVER_PublicIP HEADER
hk4e-sdk-os.mihoyo.com $SERVER_PublicIP HEADER
dispatchosglobal.yuanshen.com $SERVER_PublicIP HEADER
osusadispatch.yuanshen.com $SERVER_PublicIP HEADER
account.mihoyo.com $SERVER_PublicIP HEADER
log-upload-os.mihoyo.com $SERVER_PublicIP HEADER
dispatchcntest.yuanshen.com $SERVER_PublicIP HEADER
devlog-upload.mihoyo.com $SERVER_PublicIP HEADER
webstatic.mihoyo.com $SERVER_PublicIP HEADER
log-upload.mihoyo.com $SERVER_PublicIP HEADER
hk4e-sdk.mihoyo.com $SERVER_PublicIP HEADER
api-beta-sdk.mihoyo.com $SERVER_PublicIP HEADER
api-beta-sdk-os.mihoyo.com $SERVER_PublicIP HEADER
cnbeta01dispatch.yuanshen.com $SERVER_PublicIP HEADER
dispatchcnglobal.yuanshen.com $SERVER_PublicIP HEADER
cnbeta02dispatch.yuanshen.com $SERVER_PublicIP HEADER
sdk-os-static.mihoyo.com $SERVER_PublicIP HEADER
webstatic-sea.mihoyo.com $SERVER_PublicIP HEADER
hk4e-sdk-os-static.hoyoverse.com $SERVER_PublicIP HEADER
webstatic-sea.hoyoverse.com $SERVER_PublicIP HEADER
sdk-os-static.hoyoverse.com $SERVER_PublicIP HEADER
api-account-os.hoyoverse.com $SERVER_PublicIP HEADER
hk4e-sdk-os.hoyoverse.com $SERVER_PublicIP HEADER
overseauspider.yuanshen.com $SERVER_PublicIP HEADER
gameapi-account.mihoyo.com $SERVER_PublicIP HEADER
minor-api.mihoyo.com $SERVER_PublicIP HEADER
hk4e-sdk-os.hoyoverse.com $SERVER_PublicIP HEADER
uspider.yuanshen.com $SERVER_PublicIP HEADER
sdk-static.mihoyo.com $SERVER_PublicIP HEADER

[MITM]
hostname = api-os-takumi.mihoyo.com,hk4e-api-os-static.mihoyo.com,hk4e-sdk-os.mihoyo.com,dispatchosglobal.yuanshen.com,osusadispatch.yuanshen.com,account.mihoyo.com,log-upload-os.mihoyo.com,dispatchcntest.yuanshen.com,devlog-upload.mihoyo.com,webstatic.mihoyo.com,log-upload.mihoyo.com,hk4e-sdk.mihoyo.com,api-beta-sdk.mihoyo.com,api-beta-sdk-os.mihoyo.com,cnbeta01dispatch.yuanshen.com,dispatchcnglobal.yuanshen.com,cnbeta02dispatch.yuanshen.com,sdk-os-static.mihoyo.com,webstatic-sea.mihoyo.com,hk4e-sdk-os-static.hoyoverse.com,webstatic-sea.hoyoverse.com,sdk-os-static.hoyoverse.com,api-account-os.hoyoverse.com,hk4e-sdk-os.hoyoverse.com,overseauspider.yuanshen.com,gameapi-account.mihoyo.com,minor-api.mihoyo.com,public-data-api.mihoyo.com,uspider.yuanshen.com,sdk-static.mihoyo.com

Replace $SERVER_PublicIP by yours. On my side I set my public port to 443, might need that to work. Generate cert in Shadowrocket’s HTTPS Decryption then trust in Settings. Run Shadowrocket to take effect. In this method no mitmdump or Global HTTP Proxy in Wi-Fi settings is needed, and the server-side’s cert isn’t required to be installed.

Theoretically I think this might work.

ghost commented 2 years ago

Conv inconsistency should now properly disconnect your client now.

TheOrdinaryWow commented 2 years ago

Conv inconsistency should now properly disconnect your client now.

It seems that the problem haven’t been fixed, check following info please:

[09:32:30] [INFO] Client connected from $IP_ADDRESS
[09:32:30] [INFO] Client disconnected from $IP_ADDRESS
io.jpower.kcp.netty.KcpException: State=-1 after update()
at io.jpower.kcp.netty.UkcpServerChannel.run(UkcpServerChannel.java:395)
at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98)
at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:170)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)