Jump to content

Recommended Posts

Posted

I'm making a mod which might involve sending pretty big packets, and I came across a problem where a client disconnects if they send too big of a packet. In the logs, it said something like:

[Server Notification] Client {IP address here} disconnected, too large packet of {packet size here} bytes received

I only found one mention of this problem on the internet, here: https://github.com/mja00/VS-LiveMap-Revival/issues/30. The author of that mod documents in their fix that this packet size limit is apparently 64 kilobytes. So, my first question is if this is correct? Is the packet size limit 64 kilobytes? I couldn't find where this log might get made in any decompilation of the Vintage Story DLLs, so I couldn't verify. It would be nice to have this properly documented somewhere.

Secondly, knowing the packet size limit, what would be the best way of sending big packets while respecting this limit? The author of that mod actually fixes this issue pretty well, by compressing the big packet and then dividing it into a bunch of chunks which get sent separately. However, if I'm not mistaken interpreting the decompiled DLLs, the methods to send packets in both IServerNetworkChannel and IClientNetworkChannel seem to already compress the packets before sending them. In that LiveMap mod's case, I guess there is compression unnecessarily applied twice: once by the mod, and then by the game itself. It's probably not a big deal for performance, but it would still be preferable to have a separate method for dealing with this oneself ... and maybe that already exists with the "SendArbitraryPacket" method? I haven't looked into it that much yet, and I have no idea how to effectively use that method to communicate between the server and client. If anyone has even a basic idea of how one can send and receive packets between the client and server using those methods with "Arbitrary" in their name, please do tell about it!

  • 1 month later...
  • Solution
Posted
On 3/1/2026 at 10:57 PM, DoctorSnakes said:

I couldn't find where this log might get made in any decompilation of the Vintage Story DLLs

This would be found in the `TcpNetConnection` class, though I can't seem to inspect the code as C# only as IL code so perhaps that's why you couldn't find it.

image.thumb.png.7e22ffd9fbd854d90863b267304495da.pngA

From the looks of it the max packet size is defined in how many bytes are in the packet.

`MaxPacketSize` interestingly enough seems to be variable:  it starts of at 5000 bytes then increases to 1000000 bytes once the player identification has been completed and increases to `int.MaxValue` if the player is in creative (I guess to better allow certain creative tooling)

image.png.09201abc2fdfcf084e773994e085e52f.png

image.png.0110bc08ddcbbca8424679f14d82c824.png
 

 

On 3/1/2026 at 10:57 PM, DoctorSnakes said:

what would be the best way of sending big packets while respecting this limit?

In general the best way is to simply not send large packets. Lets say you want to update the entire visible map, well don't send the entire map in 1 packet but instead send a packet for every chunk column and update it 1 chunk column at a time.

  • Amazing! 1
Posted
On 4/8/2026 at 6:34 PM, The Insanity God said:

This would be found in the `TcpNetConnection` class, though I can't seem to inspect the code as C# only as IL code so perhaps that's why you couldn't find it.

image.thumb.png.7e22ffd9fbd854d90863b267304495da.pngA

From the looks of it the max packet size is defined in how many bytes are in the packet.

`MaxPacketSize` interestingly enough seems to be variable:  it starts of at 5000 bytes then increases to 1000000 bytes once the player identification has been completed and increases to `int.MaxValue` if the player is in creative (I guess to better allow certain creative tooling)

image.png.09201abc2fdfcf084e773994e085e52f.png

image.png.0110bc08ddcbbca8424679f14d82c824.png
 

 

In general the best way is to simply not send large packets. Lets say you want to update the entire visible map, well don't send the entire map in 1 packet but instead send a packet for every chunk column and update it 1 chunk column at a time.

Wow, thanks a lot! Good that you found the responsible class. It is really interesting that it increases it after the player identification, and it's a pretty high limit too. That log appeared right after a friend of mine that helped test joined my server, so I guess it must have happened before that "player identification" finished (I don't think I was sending anything close to a megabyte per packet).

I did decide to do essentially the same kind of approach that you describe, with inspiration from the "VS LiveMap Revival" code. However, I was then surprised to see that when I sent a lot of packets to my friend, it apparently congested the network and chat messages from my friend took a long time (30+ seconds) to be sent. At least, that's how it was for my friend, because strangely my messages were sent instantly. Probably since my client and server were the same instance. I need to experiment a bit more, maybe changing to use this max size of 1000000 bytes and sending less packets will congest less. I also hadn't done any compression or other optimization of the data structure that I was using, so doing that will also probably largely fix it.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.