gate icon indicating copy to clipboard operation
gate copied to clipboard

Forge handshack deadlock

Open LaysDragon opened this issue 3 years ago • 6 comments

It stuck at the middle of fml hand shacking. I found there is a deadlock. The gate is waiting for join server packet then will report SuccessConnectionStatus result to loginSessionHandler and turn to newInitialConnectSessionHandler to deal next client packet and forward to server. but the fml handshacking isn't finish yet,and need client proxy to pass the fml handshacking packet to server to complete the fml handshacking.but proxy side still wait for result.

https://github.com/minekube/gate/blob/f2a3859b63073fbad107f7495a09409013be4117/pkg/edition/java/proxy/session_login.go#L307-L309 Its looks like it would never return from the connectToInitialServer until complete join server packet arrived. I spent several days to playing with wireshark and writing custom dissector, trying to figure out what going on. The ConnectWithIndication is designed to blocked the proxy until a totally complete joined server. I wanted to make a PR in first place, but it seems like a flow design problem so I have no idea how to fix it without slightly refactor the current login -> join server flow. :/ Need to find a workaround to unblock the proxy side goroutine earily while the first fml handshake appear.

Forge Version: 1.12.2 14.23.5.2855

I'm curious,is there few people setup with forge server?

LaysDragon avatar Jul 23 '21 21:07 LaysDragon

After I fix the incorrect FML token https://github.com/minekube/gate/pull/34. I simply put the connectToInitialServer into anotuer goroutine. Its work but I don't known if I have break anything by doing this. So I didn't submit the PR😂. And fix another problem ,the ReadMods actually drain the data buffer and resend to server with a empty FML|HS channel packet caused out of range exception. https://github.com/LaysDragon/gate/commit/b609f4e2433f7aeb2c35f5b4e32ed98dd3006285

Now I finally get into my mod server :)

LaysDragon avatar Jul 24 '21 08:07 LaysDragon

Nan,its seems still stuck somewhere. Even I enter the world but I cant interact with world. So close to make it work.

LaysDragon avatar Jul 25 '21 15:07 LaysDragon

ok there is a extra phase in backend forge phases that will failed to complete the phase ,remove that and seems both side of connection went into complete play stage. bust still encounter bugs, most of vanilla block can interact normally. But some mod block's gui cannot be triggered and open,and seems some block have nbt data updating problem(rendering item not update after remove the item inside the block) :/

LaysDragon avatar Jul 25 '21 20:07 LaysDragon

It seems some packet might drop for unknown reason. It hard to tell what happened with so many mods, might need to build a single mod environment to narrow down the situation.

LaysDragon avatar Jul 25 '21 21:07 LaysDragon

OK,the util.go Channels func have a wrong condition will cursed backend didn't record any registered plugin channel ,that cursed non of plugin message is sending to client.

LaysDragon avatar Jul 26 '21 09:07 LaysDragon

If anyone want to check out what I have done here, you can found my modification in https://github.com/minekube/gate/compare/master...LaysDragon:fix/forge_proxy.
Its works well for me till today, but I don't known if I have done this right. So didn't throw the PR. :D
Didn't encounter any further problem after the last attempt to fix.

LaysDragon avatar Oct 06 '21 09:10 LaysDragon

Could you please check if this issue still exists? There has been many changes to the forge related code.

robinbraemer avatar Dec 07 '22 10:12 robinbraemer