Skip to content

Floodgate on Velocity throws StringIndexOutOfBoundsException in VelocityServerDataHandler #635

@DMJXMJ

Description

@DMJXMJ

Environment
Proxy: Velocity 3.4.0-SNAPSHOT (git-8f65a814-b558)
Floodgate (Velocity): 2.2.5-SNAPSHOT (b121-55a85ec)
Geyser (Velocity): 2.9.1-b999
Backend: Fabric 1.21.10 (separate Docker container)
Java: JDK 21
Deployment: itzg/mc-proxy (Velocity) + itzg/minecraft-server (Fabric) in Docker, running on the same Docker network

Velocity config (velocity.toml) – relevant parts:

[servers]
[servers.default]
address = "MCSM-fabric" # Docker hostname, container listens on 25565
# port is not explicitly specified here
[forced-hosts]
"mc.example.com" = ["default"]

Floodgate support: forward Floodgate data to backend servers

send-floodgate-data = true

Backend Fabric server is reachable inside Docker as MCSM-fabric:25565.

Description

When a Bedrock player joins through Geyser + Floodgate on Velocity, the proxy throws a StringIndexOutOfBoundsException in VelocityServerDataHandler.write and the player cannot be forwarded to the backend server (Unable to connect you to 'default').

From the stack trace it looks like Floodgate assumes the backend server address always contains a ":" (host:port), but in my case address = "MCSM-fabric" has no explicit port (Docker hostname only), which might cause lastIndexOf(':') to return -1 and lead to the Range [0, -1) error.

Log output

[14:53:07 INFO] [floodgate]: Floodgate player who is logged in as .SSS2128 ... joined
[14:53:07 INFO]: [connected player] .SSS2128 (/172.17.0.1:0) has connected

[14:53:07 ERROR]: [server connection] .SSS2128 -> default: exception encountered in LoginSessionHandler
java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 11
at java.lang.String.substring(Unknown Source) ~[?:?]
at org.geysermc.floodgate.addon.data.VelocityServerDataHandler.write(VelocityServerDataHandler.java:131) ~[?:?]
...
[14:53:07 INFO]: [connected player] .SSS2128 ... has disconnected: Unable to connect you to 'default'. Please try again later.
[14:53:07 INFO] [floodgate]: Floodgate player SSS2128 has disconnected.

Steps to reproduce
1. Run Velocity 3.4.0-SNAPSHOT with Geyser and Floodgate on Velocity (versions above).
2. In velocity.toml:
Configure the backend server without an explicit port:
[servers]
[servers.default]
address = "MCSM-fabric"
Enable Floodgate data forwarding:
send-floodgate-data = true
3. Run the backend Fabric server in another Docker container, reachable as MCSM-fabric:25565 on the same Docker network.
4. Join from a Bedrock client through Geyser (Floodgate auth).
5. Velocity throws StringIndexOutOfBoundsException in VelocityServerDataHandler.write, and the Bedrock player is disconnected with Unable to connect you to 'default'.

Expected behavior
• Floodgate should forward the connection to the backend server normally, even when the backend address in velocity.toml does not explicitly include a port, as long as Velocity itself can resolve and connect to it.

Actual behavior
• Floodgate throws StringIndexOutOfBoundsException in VelocityServerDataHandler.write, and the player is disconnected:
Unable to connect you to 'default'. Please try again later.

Additional notes
• Java Edition players can connect to the same backend through Velocity without issues.
• The problem only occurs for Bedrock players going through Geyser + Floodgate.
• It seems specifically related to send-floodgate-data = true together with a backend address that has no explicit :port.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions