pixeltris / YgoMaster

Offline Yu-Gi-Oh! Master Duel
MIT License
886 stars 127 forks source link

Issue Regarding PvP on WAN #316

Closed reredata2 closed 10 months ago

reredata2 commented 10 months ago

Hi, I trying to setup YgoMaster on WAN that I use GCP as VM and place it on docker container, there issue only in PvP every I tried to duel with my friend, and the log message said [WARNING] [Act_RoomBattleReady] Player 'Duelist' can't enter ready state as they aren't connected to the session server. except PvP duel, all feature can run smoothly without an error.

This is my Settings.json:

"BaseIP": "localhost",
"BasePort": 4989,
"SessionServerPort": 4988,
"SessionServerIP": "0.0.0.0",
"MultiplayerPvpClientConnectIP": "localhost",
"MultiplayerPvpClientConnectPort": 0,// A value of 0 will use SessionServerPort
"BindIP": "http://*:{BasePort}/",
"MultiplayerEnabled": true,// [WARNING] Only use if you know what you're doing
--- not changing for the rest ---

And this is my example ClientSettings.json:

"BaseIP": "ygoserver.example.com",
"BasePort": 4989,
"SessionServerPort": 4988,
"SessionServerIP": "{BaseIP}",
"ServerUrl": "https://{BaseIP}:{BasePort}/ygo",
"ServerPollUrl": "https://{BaseIP}:{BasePort}/ygo/poll",
"MultiplayerToken": "111934",// [WARNING] Only use this if you know what you're doing
--- not changing for the rest ---

Is there anything I'm missing? I use YgoMaster 1.42 version, and for the Firewall I also setting up port 4988-4989 for outbound and inbound in my VM on GCP and in my pc

pixeltris commented 10 months ago

Your setup sounds fine. URLs for the session server were never tested but I did code something to do a DNS lookup:

https://github.com/pixeltris/YgoMaster/blob/e13510e3dff7fe610f4db1edc4bdc7dc4a7478c0/YgoMasterClient/Program.cs#L181-L195

It's possible that code fails in an unexpected way. In ClientSettings.json enable ShowConsole and MultiplayerLogConnectionState. It might give you some insight about what's going on with the connection to the session server.

reredata2 commented 10 months ago

Previously i tried to enable what you suggest, the result is connected.

image

but if I let it idle in title screen there some additional result, here is the example image

if I try directly to use IP instead of URL, in the log say connected but there is an error in title screen, here is the example image

and in the log YgoMaster server said

[WARNING] Exception when processing message. Exception: System.Exception: TODO: A proper chunked reader
  at YgoMaster.GameServer.Process (System.Net.HttpListenerContext context) [0x012da] in <4ad568c20b1d4ceaa2edde4c2cd7e227>:0 
 Token: MTExOTM0ODEyMTcyNjM4ODI5NzF7ImFjdHMiOlt7ImFjdCI6IkFjY291bnQuU3RlYW0uZ2V0Xw==
Request: (null)
pixeltris commented 10 months ago

If I try directly to use IP instead of URL, in the log say connected

As the DNS resolved to the IP correctly there is no difference between using the IP compared to using the URL. I can't say why it stays connected using one vs the other because it's literally identical.

[WARNING] Exception when processing message. Exception: System.Exception: TODO: A proper chunked reader

As it mentions the game server doesn't support reading partial requests. It's an easy fix. Just keep reading until context.Request.ContentLength64 have been fully read.

https://github.com/pixeltris/YgoMaster/blob/e13510e3dff7fe610f4db1edc4bdc7dc4a7478c0/YgoMasterServer/GameServer.cs#L207-L209

I can't help you with your problems. You need to properly investigate what the issues are with the connections. You can do this with some combination of Wireshark and coding some additional logging inside of YgoMaster and YgoMasterClient.


Session server pinging the clients:

https://github.com/pixeltris/YgoMaster/blob/e13510e3dff7fe610f4db1edc4bdc7dc4a7478c0/YgoMasterServer/GameServer.cs#L109-L133

Session socket code: https://github.com/pixeltris/YgoMaster/blob/master/YgoMasterServer/Net/NetClient.cs

Session server connection handler: https://github.com/pixeltris/YgoMaster/blob/master/YgoMasterServer/Net/NetServer.cs

Some session request handlers on the client side (including the ping handler): https://github.com/pixeltris/YgoMaster/blob/e13510e3dff7fe610f4db1edc4bdc7dc4a7478c0/YgoMasterClient/DuelDll.cs#L789-L806


Good luck!