CC: Tweaked

CC: Tweaked

59M Downloads

max_websocket_message not being respected

campbellcole opened this issue · 3 comments

commented

Minecraft Version

1.19.x

Version

1.101.3

Details

I am trying to send a relatively large JSON string over a websocket. The string is 334992 characters long. Assuming worst case encoding (3 bytes per character), this string should be around 981 KiB. I have tried setting the max_websocket_message value to 0, 4194304 (4 MiB), and 1073741824 (1 GiB), and in all cases the error Message is too large still appears.

The applicable rule is the only rule in the http.rules array. I have also set the http.bandwidth.global_* options to the same permutations as above, as well as 99999999. This has no effect.

Am I hitting a limitation of WebSockets themselves? I have searched through the code and can't see any reason why this is happening. The reason I think the value isn't being respected is because the only possible way to hit this error (that I could find) is

if( options.websocketMessage != 0 && text.length() > options.websocketMessage )
and the condition clearly states that setting the value to zero would skip the check entirely, and that doesn't work.

I also saw that the default value for this config option is 128KiB. I am going to test whether or not this is the limit being used by crafting a string of roughly that size and trying to send it.

Thanks

commented

It appears the default value is being used (128 KiB). If I try to send a message of that size, the receive method returns nil and my program interprets that as a hang-up (as the documentation says to). I'm going to try to replicate this using a debugger so I can inspect the options being used, and maybe why they aren't being respected.

Edit: Stepping through with a debugger shows that the option is not being respected. No matter what the config sets it to, the value is fixed at 131072. I will continue debugging to see if I can fix the issue.

commented

Ok, I have figured out the issue. The problem is that the automatically generated config uses the key max_websocket_message when the key should be websocket_message. I think using max_websocket_message makes more sense, but it's your call.

Either way, the fix is to change all occurrences of max_websocket_message to websocket_message in the config, and the value will be respected.

commented

Thank you for the report, and all the extra effort in debugging this! That was a very silly bug on my end :/.