New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket: Fix some non-blocking connect edge cases #10700
Conversation
Please rebase this so the Android build passes. |
Is there a Monster Hunter Tri server I can connect to in order to test this? |
@JMC47 You will need this Riivolution patch to allow the game to connect to custom servers. You should also try this with a hunter profile which doesn't have online data (or you should backup your save) as it might alter some of its online properties. On real hardware, you will only need to setup the Internet connection with the server IP as primary DNS and launch the game with the Riivolution patch. On Dolphin you will need to add the following lines in your hosts file and launch the game with Riivolution:
You should also delete said lines when done testing to remove the redirections. The test server should allow you to pass the login process on real hardware but will fail on Dolphin (without this PR) with the error code 11602. BTW, my test server might not allow you to connect to online lobbies and might display python error messages. Regardless, it should be good enough to illustrate this connection issue related to the login process. |
For the HWTEST, you have |
It's not a copy-paste error. The Wii takes enough time to connect and send the packet successfully. However, Dolphin is too fast, so instead of returning Though, it does fix the issue because I assume this difference might be caused by a timing issue which might not be entirely network related. |
@iwubcode |
@sepalani - thanks so much. One minor comment, otherwise LGTM. |
Workaround for mbedtls handshake issues with partially connected sockets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Untested. LGTM
I don't know exactly how much functionality is on the servers, but I'd be willing to merge this. I haven't had a chance to test it yet, but I'll try to get to it tonight. |
I was wondering why during the wii-network branch development, the issue wasn't detected when the original servers for MH3 were still up. Then I realised that it wasn't using mbedTLS (known as PolarSSL back then) but GnuTLS/OpenSSL instead and was supporting non-blocking handshakes. The western MH3 servers closed on April 2013 and around August 2013 Dolphin changed its SSL library with the one that we're currently using today. I think that's why this issue went unnoticed for so long, especially since the few games having it weren't playable online anymore. |
Ignore previous comment, I did not follow instructions properly because I didn't read through them thoroughly and missed a step. I got pretty far in before encountering an error - much further than master will get. Is this as much as I'm supposed to see? Edit: Looks like it based on your previous post. I never got a chance to play this on the actual servers, so I wasn't sure how many steps were are, but this appears to be the part where you said it might not load. So it LGTM in terms of what is expected. |
@JMC47 If you want to go further, you should be able to circumvent this error message by choosing an empty city gate. The recommended way is to self host the custom server, atm. My test server being for testing purpose, it's not the latest stable version. Multiplayer support isn't (officially) supported by the custom server yet. I wouldn't recommend playing it unless you're really fond of the game as it's more difficult, especially while doing it solo. By the way, don't forget to remove these entries from your |
Socket: Fix some non-blocking connect edge cases
Some Capcom games (namely, Monster Hunter 3 and Monster Hunter G) use non-blocking connect then directly call some network/ssl functions. Unfortunately, it seems that mbedtls doesn't support SSL handshake when the connection is in progress (i.e. not fully completed yet). The same happens with network calls returning
ENOTCONN
instead ofEAGAIN
. In sum, the games will abort the connection if Dolphin isn't quick enough to connect before the network function is called. Obviously, it doesn't happen if you host locally the servers that the games are connecting to. However, it will happen if they are on the Internet and the network is too slow.This PR refactors parts of the network code and fix some error codes. I'm unaware of other games affected by this issues. I wrote 2 hardware tests, one for the SSL handshake (wii-ssl-connect.zip), the other one for the send/recv (wii-net-connect.zip).
HWTEST - SSL Connect (naswii.nintendowifi.net:443)
HWTEST - Non-blocking NET Connect (8.8.8.8:53)
Ready to be reviewed & tested.