Network icon indicating copy to clipboard operation
Network copied to clipboard

Unable to connect to some servers (probably those that use the pocketmine core)

Open nikolayKeniston opened this issue 9 months ago • 2 comments

The client does not receive a response to the open connection request packet from server, probably the server does not expect it. However, according to the raknet documentation (https://wiki.vg/Raknet_Protocol), the implementation does everything correctly, and any raknet server must accept a sequence of handshakes/open connection requests in the described way. However, some servers (in particular those using Pocketmine as their core) do not respond to the first connection open request packet and all subsequent. Also I noticed that the Minecraft client decides based on pong data whether to send handshakes to the server or not (in addition, https://github.com/PrismarineJS/bedrock-protocol always pings the server before connecting and changes the behavior depending on the response), although I did not quite understand what exactly should be in pong to change the behavior of an open connection. Maybe Raknet supports the outdated way of opening connections, and if the pong came in an outdated format, the client uses an outdated way to open the connection? I also tried changing the rak_protocol_version and rak_mtu options, but it didn't help. Moreover, ping works great. In general, this implementation and projects using it cannot open a connection with the some raknet servers (e.g. casescraft.ru:19133) at the handshake level. I would like to know if I have not understood something or if this is a bug?

nikolayKeniston avatar May 01 '24 10:05 nikolayKeniston

The client does not receive a response to the open connection request packet from server, probably the server does not expect it. However, according to the raknet documentation (https://wiki.vg/Raknet_Protocol), the implementation does everything correctly, and any raknet server must accept a sequence of handshakes/open connection requests in the described way. However, some servers (in particular those using Pocketmine as their core) do not respond to the first connection open request packet and all subsequent.

What is defined on wiki.vg is not really a specification. Since the vanilla client can do whatever it wants, many server implementations tailor things to this. I can try to see if I can get Pocketmine working in my fork of network if you have an example of a server I can connect to? Also, can you confirm in wireshark that it is actually not sending any of these packets? Or were you just trying to log them with this lib?

Also I noticed that the Minecraft client decides based on pong data whether to send handshakes to the server or not (in addition, https://github.com/PrismarineJS/bedrock-protocol always pings the server before connecting and changes the behavior depending on the response), although I did not quite understand what exactly should be in pong to change the behavior of an open connection.

Nothing in particular is in the ping data, but some server implementations may use this mechanism to try to detect spoofed clients. The vanilla client constantly pings all servers on its list, even if it is actively on a server. So I imagine some server implementations keep a record of recent pings and refuse to allow clients that have not pinged it in some time, and prismarine is trying to get around this.

In general, this implementation and projects using it cannot open a connection with the some raknet servers (e.g. casescraft.ru:19133) at the handshake level. I would like to know if I have not understood something or if this is a bug?

The client side of this lib is largely designed based based on the expectations that the server the client is connecting to will behave similarly to the server side of this lib.

Kas-tle avatar May 03 '24 14:05 Kas-tle

Thanks a lot! If anyone is reading in the future, here is a working solution from Kastle: https://github.com/Kas-tle/Network/blob/13ba1e504844878e63003ec644315e8524e2cd2f/transport-raknet/src/main/java/org/cloudburstmc/netty/handler/codec/raknet/client/RakClientOfflineHandler.java#L189-L200

nikolayKeniston avatar May 04 '24 10:05 nikolayKeniston