koraktor / steam-condenser

A multi-language library for querying the Steam Community, Source, GoldSrc servers and Steam master servers
https://koraktor.de/steam-condenser
Other
356 stars 67 forks source link

BufferUnderflowException over 100 players #319

Closed gibbonsjohnm closed 6 years ago

gibbonsjohnm commented 6 years ago

Anytime one of my servers have over 100 active players, I receive the following error:

Caused by: java.nio.BufferUnderflowException at java.nio.ByteArrayBuffer.getInt(ByteArrayBuffer.java:196) at com.github.koraktor.steamcondenser.PacketBuffer.getInt(PacketBuffer.java:67) at com.github.koraktor.steamcondenser.steam.packets.S2A_PLAYER_Packet.<init>(S2A_PLAYER_Packet.java:49) at com.github.koraktor.steamcondenser.steam.packets.SteamPacketFactory.getPacketFromData(SteamPacketFactory.java:60) at com.github.koraktor.steamcondenser.steam.sockets.SteamSocket.getPacketFromData(SteamSocket.java:78) at com.github.koraktor.steamcondenser.steam.sockets.SourceSocket.getReply(SourceSocket.java:105) at com.github.koraktor.steamcondenser.steam.servers.GameServer.getReply(GameServer.java:270) at com.github.koraktor.steamcondenser.steam.servers.GameServer.handleResponseForRequest(GameServer.java:330) at com.github.koraktor.steamcondenser.steam.servers.GameServer.handleResponseForRequest(GameServer.java:286) at com.github.koraktor.steamcondenser.steam.servers.GameServer.updatePlayers(GameServer.java:529) at com.github.koraktor.steamcondenser.steam.servers.GameServer.getPlayers(GameServer.java:205) at com.github.koraktor.steamcondenser.steam.servers.GameServer.getPlayers(GameServer.java:182)

I am developing on Android so I'm not positive if that has anything to do with it. I don't have any issues with servers that have < 100 players.

koraktor commented 6 years ago

What kind of game server is this?

AFAIK there aren’t any Source games that support more than 64 players.

gibbonsjohnm commented 6 years ago

Garry's Mod

koraktor commented 6 years ago

Ok. Do you have an IP to test with?

gibbonsjohnm commented 6 years ago

Sure thing. Grabbed one from gametracker:

208.103.169.12:27015

koraktor commented 6 years ago

It seems Garry's Mod is sending corrupt data in the S2A_PLAYER packet. The data is obviously cut at the end (verified with Wireshark), so the exception is thrown correctly.

Usually Source sends split data packets in such a situation (see VDC). I think this is a bug in Garry’s Mod.

gibbonsjohnm commented 6 years ago

This also happens with Rust. It appears anytime the player count is over 64, this happens.

koraktor commented 6 years ago

But Rust is not a Source engine game, it only uses its query protocol. Although this should be no problem if implemented in the right way.

As said earlier Source has had an official limit of 32 players, raised to 64 in some engine update later on for CS:GO. Garry’s Mod has it’s own limit of 128.

I currently don’t see a chance to fix this problem inside the library. Sorry about that.

gibbonsjohnm commented 6 years ago

No problem! Thanks for investigating.