ViaVersion / VIAaaS

ViaVersion as a Service - standalone ViaVersion proxy
https://viaversion.github.io/VIAaaS
GNU Affero General Public License v3.0
162 stars 12 forks source link

Cannot receive string longer than Short.MAX_VALUE * 3 bytes (got 1256 bytes) #202

Closed HSGamer closed 2 years ago

HSGamer commented 2 years ago
2022-06-09 00:16:28 [epollEventLoopGroup-3-10] [VIAaaS MC] D Exception: 
io.netty.handler.codec.DecoderException: java.lang.IllegalArgumentException: Cannot receive string longer than Short.MAX_VALUE * 3 bytes (got 1256 bytes)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:98) ~[VIAaaS.jar:?]
    at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[VIAaaS.jar:?]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[VIAaaS.jar:?]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[VIAaaS.jar:?]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[VIAaaS.jar:?]
    at io.netty.handler.flow.FlowControlHandler.dequeue(FlowControlHandler.java:200) ~[VIAaaS.jar:?]
    at io.netty.handler.flow.FlowControlHandler.channelRead(FlowControlHandler.java:162) ~[VIAaaS.jar:?]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[VIAaaS.jar:?]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[VIAaaS.jar:?]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[VIAaaS.jar:?]
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327) ~[VIAaaS.jar:?]
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:314) ~[VIAaaS.jar:?]
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:435) ~[VIAaaS.jar:?]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279) ~[VIAaaS.jar:?]
    at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:103) ~[VIAaaS.jar:?]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[VIAaaS.jar:?]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[VIAaaS.jar:?]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[VIAaaS.jar:?]
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[VIAaaS.jar:?]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[VIAaaS.jar:?]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[VIAaaS.jar:?]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[VIAaaS.jar:?]
    at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:800) ~[VIAaaS.jar:?]
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:487) ~[VIAaaS.jar:?]
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:385) ~[VIAaaS.jar:?]
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:995) ~[VIAaaS.jar:?]
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[VIAaaS.jar:?]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[VIAaaS.jar:?]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.IllegalArgumentException: Cannot receive string longer than Short.MAX_VALUE * 3 bytes (got 1256 bytes)
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:167) ~[VIAaaS.jar:?]
    at com.viaversion.viaversion.api.type.types.StringType.read(StringType.java:50) ~[VIAaaS.jar:?]
    at com.viaversion.aas.codec.packet.handshake.Handshake.decode(Handshake.kt:18) ~[VIAaaS.jar:?]
    at com.viaversion.aas.codec.packet.PacketRegistry.decode(PacketRegistry.kt:164) ~[VIAaaS.jar:?]
    at com.viaversion.aas.codec.MinecraftCodec.decode(MinecraftCodec.java:48) ~[VIAaaS.jar:?]
    at com.viaversion.aas.codec.MinecraftCodec.decode(MinecraftCodec.java:18) ~[VIAaaS.jar:?]
    at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[VIAaaS.jar:?]
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[VIAaaS.jar:?]
    ... 28 more
2022-06-09 00:16:28 [epollEventLoopGroup-3-10] [VIAaaS MC] D - /[REACTED]:64657: io.netty.handler.codec.DecoderException: java.lang.IllegalArgumentException: Cannot receive string longer than Short.MAX_VALUE * 3 bytes (got 1256 bytes)
2022-06-09 00:16:28 [epollEventLoopGroup-3-10] [VIAaaS MC] D - /[REACTED]:64657: -

I don't know why it happens. This may need some investigations to gather enough evidences to resolve.

I use VIAaaS as an MiTM for connecting BungeeCord with my custom server. This occurs on the proxy. I did suspect it as my custom server's issue, so I swapped to an Spigot server and had no luck.

Here is the proxy's config

# ######################
# Some configurations need a restart
# See https://ktor.io/docs/configurations.html#command-line for https interface options
# ######################
# 
# #####
# Minecraft networking
# #####
# Socket address to bind, default port is 25565
bind-addresses:
- 0.0.0.0:9104
# Proxy used to connect to backend servers
# Example: socks5://localhost:9050, socks4://localhost:9050, http://foo:bar@localhost:9080
backend-proxy: ''
# Zlib Compression level
compression-level: 1
# 
# #####
# VIAaaS virtual hosts options
# #####
# Requires virtual host to contain the value from "host-name" as a suffix.
# A false value will allow virtual hosts with no suffix, connecting to the hostname sent by client.
# A false value could be used for transparent proxying or for MiTM.
require-host-name: false
# Host names of this instance. Will be used as a suffix.
host-name:
- viaaas.localhost
- via.localhost
- via.localho.st
default-backend-port: 25565
default-parameters:
  -1: localhost._p9201
block-local-address: false
blocked-back-addresses: []
allowed-back-addresses:
- '*'
show-version-ping: false
show-brand-info: false
rate-limit-ws: 1.5
rate-limit-connection-mc: 10.0
rate-limit-login-mc: 0.2
listening-ws-limit: 10
favicon-url: https://raw.githubusercontent.com/ViaVersion/VIAaaS/396dcb40249ed0ef292e223c32e7f130699e7153/src/main/resources/web/logo.png
force-online-mode: false
max-players: 20
protocol-detector-cache: 5
jwt-secret: r444KdCC/H9Re/XmDg0evxaZ7KPo0KnH1I70VYtzvsOABGnhGg3ZzhJMxgadEQosRz1CBhH7JDARvmqtncrQ0g==
backend-address: ''

9104 is opened and linked to BungeeCord 9201 is the custom server's port

HSGamer commented 2 years ago

Turn out the address from the Handshake packet from my server is looking something like this

2022-06-09 11:49:57 [epollEventLoopGroup-3-2] [VIAaaS MC] D Handshake: _[REACTED]._minecraft._tcp.[REACTED] [REACTED-IPv4] [REACTED-CLOUD-ID??] [{"name":"textures","value":"ewogICJ0aW1lc3RhbXAiIDogMTY1NDcwODQ3ODA1MCwKICAicHJvZmlsZUlkIiA6ICI1ZmVhNDg4MGExMDQ0Y2RlOWFkOGNhYWU2NTJjNzdlNyIsCiAgInByb2ZpbGVOYW1lIiA6ICJTdGFuZFRoZXJlQmFja2VyIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzJiNjFlZWRkM2UyZGZlMWE4ZTFmZGY0ZmUzZ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