minekube / gate

High-performance, resource-efficient Minecraft reverse proxy with robust multi-protocol version support. Designed as a scalable Velocity/BungeeCord alternative, suitable for both development and large-scale deployments. Proven in production environments, powering our global Connect edge proxy network.
https://gate.minekube.com
Apache License 2.0
657 stars 57 forks source link

(1.18) Can't connect to server with onlineMode=true #80

Closed AlyxPractice closed 2 years ago

AlyxPractice commented 2 years ago

Hi,

First thanks for this project, it's amazing what you have built here and I'll try to contribute as much as I can 🙇

I'm having some trouble making it work on a Kubernetes cluster (I haven't tried in a more native way yet). When I enabled the onlineMode on gate, I can't connect anymore, no matter the setting of the vanilla server behind (i'm using github.com/itzg/docker-minecraft-server for this).

Context:

Dockerfile.gate

This image is being run on the Kubernetes cluster

FROM golang:alpine
EXPOSE 25565
RUN go install go.minekube.com/gate@latest
CMD gate

gate logs:

2022-07-29T11:29:46.051Z    LEVEL(-2)   java.client.decoder codec/decoder.go:96 decoded packet  {"context": "PacketContext:direction=ServerBound,Protocol=4,KnownPacket=true,PacketID=0,PacketType=*packet.Handshake,Payloadlen=28"}
2022-07-29T11:29:46.051Z    LEVEL(-2)   java.client.decoder codec/decoder.go:96 decoded packet  {"context": "PacketContext:direction=ServerBound,Protocol=758,KnownPacket=true,PacketID=0,PacketType=*packet.ServerLogin,Payloadlen=9"}
2022-07-29T11:29:46.051Z    LEVEL(-2)   java.client.encoder codec/encoder.go:96 encoded packet  {"context": "PacketContext:direction=ClientBound,Protocol=758,KnownPacket=true,PacketID=1,PacketType=*packet.EncryptionRequest,Payloadlen=0", "bytes": 171}
2022-07-29T11:29:46.238Z    LEVEL(-2)   java.client.decoder codec/decoder.go:96 decoded packet  {"context": "PacketContext:direction=ServerBound,Protocol=758,KnownPacket=true,PacketID=1,PacketType=*packet.EncryptionResponse,Payloadlen=261"}
2022-07-29T11:29:46.239Z    DEBUG   java.client.loginSession.authn.authnJoin.request    auth/authenticator.go:168   Sending http request to Mojang sessionserver    {"url": "https://sessionserver.mojang.com/session/minecraft/hasJoined?serverId=xxx&username=my_minecraft_name"}
2022-07-29T11:29:46.405Z    DEBUG   java.client.loginSession.authn.authnJoin.request    auth/authenticator.go:198   User was tested against Mojang sessionserver    {"onlineMode": true, "time": "166.380917ms", "statusCode": 200}
2022-07-29T11:29:46.405Z    INFO    java.client.authSession proxy/sesssion_auth.go:61   player has connected, completing login  {"player": "my_minecraft_name", "id": "xxx"}
2022-07-29T11:29:46.405Z    LEVEL(-2)   java.client.encoder codec/encoder.go:96 encoded packet  {"context": "PacketContext:direction=ClientBound,Protocol=758,KnownPacket=true,PacketID=3,PacketType=*packet.SetCompression,Payloadlen=0", "bytes": 3}
2022-07-29T11:29:46.406Z    DEBUG   java.client proxy/connection.go:424 update compression  {"threshold": 256}
2022-07-29T11:29:46.406Z    LEVEL(-2)   java.client.encoder codec/encoder.go:96 encoded packet  {"context": "PacketContext:direction=ClientBound,Protocol=758,KnownPacket=true,PacketID=2,PacketType=*packet.ServerLoginSuccess,Payloadlen=0", "bytes": 25}
2022-07-29T11:29:46.406Z    DEBUG   java.client.player.serverConn   proxy/server.go:332 connecting to server... {"name": "my_minecraft_name", "id": "xxx", "serverName": "server1", "serverAddr": "minecraft:25570"}
2022-07-29T11:29:46.406Z    DEBUG   java.client.player.serverConn   proxy/server.go:337 connected to server {"name": "my_minecraft_name", "id": "xxx", "serverName": "server1", "serverAddr": "minecraft:25570"}
2022-07-29T11:29:46.407Z    DEBUG   java.client.player.serverConn   proxy/server.go:353 establishing player connection with server...   {"name": "my_minecraft_name", "id": "xxx", "serverName": "server1", "serverAddr": "minecraft:25570"}
2022-07-29T11:29:46.407Z    LEVEL(-2)   java.server.encoder codec/encoder.go:96 encoded packet  {"context": "PacketContext:direction=ServerBound,Protocol=4,KnownPacket=true,PacketID=0,PacketType=*packet.Handshake,Payloadlen=0", "bytes": 1282}
2022-07-29T11:29:46.407Z    LEVEL(-2)   java.server.encoder codec/encoder.go:96 encoded packet  {"context": "PacketContext:direction=ServerBound,Protocol=758,KnownPacket=true,PacketID=0,PacketType=*packet.ServerLogin,Payloadlen=0", "bytes": 9}
2022-07-29T11:29:46.407Z    DEBUG   java.server proxy/connection.go:125 Error reading packet, closing connection    {"err": "error reading varint frame: error reading varint: EOF"}
2022-07-29T11:29:46.407Z    DEBUG   java.client.player  proxy/switch.go:161 could not connect player to server  {"name": "my_minecraft_name", "id": "xxx", "serverName": "server1", "serverAddr": "minecraft:25570", "err": "The connection to the remote server was unexpectedly closed.\nThis is usually because the remote server does not have BungeeCord IP forwarding correctly enabled."}
2022-07-29T11:29:46.407Z    INFO    java.client.player  proxy/switch.go:174 unable to connect to server {"name": "my_minecraft_name", "id": "xxx", "serverName": "server1", "serverAddr": "minecraft:25570", "error": "The connection to the remote server was unexpectedly closed.\nThis is usually because the remote server does not have BungeeCord IP forwarding correctly enabled."}
2022-07-29T11:29:46.407Z    LEVEL(-2)   java.client.encoder codec/encoder.go:96 encoded packet  {"context": "PacketContext:direction=ClientBound,Protocol=758,KnownPacket=true,PacketID=1a,PacketType=*packet.Disconnect,Payloadlen=0", "bytes": 81}
2022-07-29T11:29:46.407Z    DEBUG   java.client proxy/connection.go:125 Error reading packet, closing connection    {"err": "error reading varint frame: error reading varint: read tcp 127.0.0.1:25565->127.0.0.1:42998: use of closed network connection"}
2022-07-29T11:29:46.407Z    INFO    java.client.player  proxy/player.go:597 Player has been disconnected    {"name": "my_minecraft_name", "id": "xxx", "reason": "§cUnable to connect to \"server1\". Try again later."}

gate config.yml:

editions:
  java:
    enabled: true
    config:
      bind: 0.0.0.0:25565
      servers:
        server1: minecraft:25570
      try:
        - server1

server.properties:

enable-jmx-monitoring=false
level-seed=
rcon.port=25575
enable-command-block=true
gamemode=survival
enable-query=false
generator-settings={}
level-name=world
motd=A Vanilla Minecraft Server powered by Docker
query.port=25565
texture-pack=
pvp=true
generate-structures=true
difficulty=easy
network-compression-threshold=256
max-tick-time=60000
require-resource-pack=false
max-players=20
use-native-transport=false
online-mode=false
enable-status=true
allow-flight=false
broadcast-rcon-to-ops=true
view-distance=10
max-build-height=256
server-ip=
resource-pack-prompt=
allow-nether=true
server-port=25565
enable-rcon=true
sync-chunk-writes=true
op-permission-level=4
prevent-proxy-connections=false
hide-online-players=false
resource-pack=
entity-broadcast-range-percentage=100
simulation-distance=10
player-idle-timeout=0
rcon.password=minecraft
force-gamemode=false
rate-limit=0
hardcore=false
white-list=false
broadcast-console-to-ops=true
spawn-npcs=true
spawn-animals=true
snooper-enabled=true
function-permission-level=2
level-type=default
text-filtering-config=
spawn-monsters=true
enforce-whitelist=false
resource-pack-sha1=
spawn-protection=16
max-world-size=29999984

If I disable the online mode, I can connect, so I guess there is something related to this? I'm a bit lost on what to try next, if you have any hints, that would be super helpful.

Thanks a lot!

robinbraemer commented 2 years ago

Do you have bungeecord enabled in spigot.yml? See example https://github.com/minekube/gate/blob/master/examples/simple-network/server1/spigot.yml

This log message This is usually because the remote server does not have BungeeCord IP forwarding correctly enabled. usually is the hint if bungeecord is not yet enabled.

AlyxPractice commented 2 years ago

Thanks for your answer. Sorry I forgot to send the details of the MC server I was running. I was running Fabric, not spigot.

Here's a working env with Tilt (Kubernetes / Docker) so you can "easily" run it locally (if you have Tilt installed + Docker + Kubernetes). If you don't, at least you can check the configuration of all the yaml files.

gate_issue_80.zip

robinbraemer commented 2 years ago

The minecraft server is not configured correctly. Add this env to your minecraft-deployment

        - name: ONLINE_MODE
          value: "false"
AlyxPractice commented 2 years ago

Maybe it should be added to the documentation that it can't run with ONLINE_MODE=true then?

robinbraemer commented 2 years ago

Yes, absolutely! I'll continue working on the documentation.