lloesche / valheim-server-docker

Valheim dedicated gameserver with automatic update, World backup, BepInEx and ValheimPlus mod support
https://hub.docker.com/r/lloesche/valheim-server
Apache License 2.0
1.96k stars 276 forks source link

Waiting for server to listen on UDP port 2456 #483

Open DarwishCodes opened 2 years ago

DarwishCodes commented 2 years ago

I'm running arm64 from Oracle Cloud. and using tonistiigi/binfmt. Please, take a look at the log :

2022-06-11 17:55:50,401 INFO success: valheim-bootstrap entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
Jun 11 17:55:50 cron[57]: (CRON) INFO (pidfile fd = 3)
Jun 11 17:55:50 cron[57]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Jun 11 17:55:50 /supervisord: valheim-bootstrap DEBUG - [59] - Running commit 02869a15a06a4429cfa5ddb481f78238b7219b7a
Jun 11 17:55:50 /supervisord: valheim-bootstrap DEBUG - [59] - Creating cron to do world backups using schedule 0 * * * *
Jun 11 17:55:50 /supervisord: valheim-bootstrap DEBUG - [59] - Creating cron to check for updates using schedule */15 * * * *
Jun 11 17:55:50 /supervisord: valheim-bootstrap DEBUG - [59] - Creating cron to restart valheim-server using schedule 0 5 * * *
Jun 11 17:55:50 crontab[79]: (root) REPLACE (root)
2022-06-11 17:55:51,992 INFO success: syslogd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-06-11 17:55:51,993 INFO success: crond entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-06-11 17:55:53,118 INFO spawned: 'valheim-updater' with pid 88
Jun 11 17:55:53 /supervisord: valheim-updater DEBUG - [88] - Running Valheim Server updater as user valheim uid 0
Jun 11 17:55:53 /supervisord: valheim-updater DEBUG - [88] - Kernel: Linux 86c23b621ec5 5.15.0-1009-oracle #12-Ubuntu SMP Thu Jun 2 11:44:09 UTC 2022 x86_64 GNU/Linux
Jun 11 17:55:53 /supervisord: valheim-updater DEBUG - [88] - Unable to determine CPU Frequency - setting a default of 1.5 GHz so steamcmd won't complain
Jun 11 17:55:54 /supervisord: valheim-updater DEBUG - [88] - Memory total/free/available: 78080960/72138204/75991420
Jun 11 17:55:54 /supervisord: valheim-updater DEBUG - [88] - Storage configuration:
2022-06-11 17:55:54,116 INFO success: valheim-updater entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
Jun 11 17:55:54 /supervisord: valheim-updater Filesystem      Size  Used Avail Use% Mounted on
Jun 11 17:55:54 /supervisord: valheim-updater overlay          45G  8.2G   37G  19% /
Jun 11 17:55:54 /supervisord: valheim-updater /dev/sda1        45G  8.2G   37G  19% /config
Jun 11 17:55:54 /supervisord: valheim-bootstrap valheim-updater: started
Jun 11 17:55:54 /supervisord: valheim-updater overlay / overlay rw,relatime,lowerdir=/var/lib/docker/overlay2/l/YPAQWOUWDBHH2VH4YV4LWH4XPG:/var/lib/docker/overlay2/l/QLAMSOFFRPVLTC2QZL4Q6OQPGB:/var/lib/docker/overlay2/l/CQBSEKBSFEEVXFP7MDVX3FGSA3:/var/lib/docker/overlay2/l/ICUOOCXAGSG5SWIEI76UFCOBBS:/var/lib/docker/overlay2/l/UWGJWQMQUSSQPZIQKPZPIZR7RF,upperdir=/var/lib/docker/overlay2/34af5cd917cbb79591672b85ccbe7587a3ef3713d87c80df3daf803216a27519/diff,workdir=/var/lib/docker/overlay2/34af5cd917cbb79591672b85ccbe7587a3ef3713d87c80df3daf803216a27519/work 0 0
Jun 11 17:55:54 /supervisord: valheim-updater /dev/sda1 /config ext4 rw,relatime,discard,errors=remount-ro 0 0
Jun 11 17:55:54 /supervisord: valheim-updater /dev/sda1 /opt/valheim ext4 rw,relatime,discard,errors=remount-ro 0 0
2022-06-11 17:55:56,342 INFO spawned: 'valheim-backup' with pid 155
Jun 11 17:55:56 /supervisord: valheim-updater DEBUG - [88] - Valheim updater was just started - skipping connected players check
Jun 11 17:55:56 /supervisord: valheim-updater INFO - Downloading/updating/validating Valheim server from Steam
Jun 11 17:55:56 /supervisord: valheim-backup DEBUG - [155] - No Valheim worlds to backup
Jun 11 17:55:56 /supervisord: valheim-backup DEBUG - [155] - No old backups to remove
2022-06-11 17:55:57,854 INFO success: valheim-backup entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
Jun 11 17:55:57 /supervisord: valheim-bootstrap valheim-backup: started
2022-06-11 17:55:57,970 INFO exited: valheim-bootstrap (exit status 0; expected)
Jun 11 17:56:00 /supervisord: valheim-updater Bail out! ERROR:../target/i386/tcg/translate.c:8571:i386_tr_init_disas_context: assertion failed: (IOPL(dc) == iopl)
Jun 11 17:56:00 /supervisord: valheim-updater /opt/steamcmd/steamcmd.sh: line 39:   188 Aborted                 (core dumped) $DEBUGGER "$STEAMEXE" "$@"
Jun 11 17:56:00 /supervisord: valheim-updater ERROR - Failed to update Valheim server from Steam - however an existing version was found locally - using it
Jun 11 17:56:00 /supervisord: valheim-updater INFO - Valheim Server is already the latest version
Jun 11 17:56:00 /supervisord: valheim-updater DEBUG - [88] - Writing file to start Valheim server
Jun 11 17:56:01 cron[57]: (root) RELOAD (crontabs/root)
2022-06-11 17:56:05,105 INFO spawned: 'valheim-server' with pid 235
Jun 11 17:56:05 /supervisord: valheim-server INFO - Running Valheim Server
Jun 11 17:56:05 /supervisord: valheim-server DEBUG - [235] - Server config is name: My Server, port: 2456/udp, world: Neotopia, public: 1, mod: none
Jun 11 17:56:05 /supervisord: valheim-server DEBUG - [235] - Waiting for server to listen on UDP port 2456
Jun 11 17:56:05 /supervisord: valheim-server I0611 17:56:05.684557     257 main.go:76] Configuring Valheim server log filter
Jun 11 17:56:05 /supervisord: valheim-server I0611 17:56:05.693836     257 main.go:96] Removing log lines starting with 'src/steamnetworkingsockets/clientlib/steamnetworkingsockets_lowlevel.cpp'
Jun 11 17:56:05 /supervisord: valheim-server I0611 17:56:05.694489     257 main.go:122] Removing empty log lines: true
Jun 11 17:56:05 /supervisord: valheim-server I0611 17:56:05.694861     257 main.go:125] Removing invalid UTF-8 chars: true
Jun 11 17:56:05 /supervisord: valheim-server I0611 17:56:05.695076     257 main.go:89] Removing log lines matching ' '
Jun 11 17:56:05 /supervisord: valheim-server I0611 17:56:05.695332     257 main.go:96] Removing log lines starting with '(Filename:'
Jun 11 17:56:05 /supervisord: valheim-server Found path: /opt/valheim/server/valheim_server.x86_64
Jun 11 17:56:05 /supervisord: valheim-server Mono path[0] = '/opt/valheim/server/valheim_server_Data/Managed'
Jun 11 17:56:05 /supervisord: valheim-server Mono config path = '/opt/valheim/server/valheim_server_Data/MonoBleedingEdge/etc'
Jun 11 17:56:06 /supervisord: valheim-server Preloaded 'libsteam_api.so'
Jun 11 17:56:10 /supervisord: valheim-server DEBUG - [235] - Waiting for server to listen on UDP port 2456
2022-06-11 17:56:15,710 INFO success: valheim-server entered RUNNING state, process has stayed up for > than 10 seconds (startsecs)
Jun 11 17:56:15 /supervisord: valheim-updater valheim-server: started
Jun 11 17:56:15 /supervisord: valheim-server DEBUG - [235] - Waiting for server to listen on UDP port 2456

I've port forwarded 2456.

Thanks

tmoerkerken commented 2 years ago

For me it took a while in order for the router to update the port forwarding.

DarwishCodes commented 2 years ago

For me it took a while in order for the router to update the port forwarding.

Thanks for your reply. Also, sorry for late reply. I didn't figure out where the problem is till this day, But thanks so much for your reply.

hyunjaekim commented 2 years ago

The exact same problem is happening to me. I deployed it on my apple M1 mac mini, using docker-compose. I'm using a iptime router and fort forwarded from 2456-2458 to 2456-2458 on TCP & UDP.

Update: I followed steps on my intel macbook, and successed. Maybe it is a part of apple silicon problem.

passivedragon commented 1 year ago

I'm running into this exact issue on an ubuntu LXC, tried a couple of methods of defining and starting the server, but no luck so far.

My setup is on a Proxmox hypervisor, all ports are forwarded and the machine is accessible, but no luck.

At the moment I am using the provided default docker_compose configuration, with barely any change.

Aiiion commented 1 year ago

I had this same issue after restarting my container. Another restart and it was solved. It took a while for the container to spin up but that solved it.

Heiland commented 1 year ago

Same issue: 'Waiting for server to listen on UDP port 2456' every 5 seconds. Clients cannot connect to the server.

Ports are forwarded by iptables on the host machine.

jasonewall commented 1 year ago

@DarwishCodes Is there a reason why you're trying to run this on an ARM machine? while binfmt works it tends to run at about 1/5 the performance of the intended target. that might be causing the delay in the port binding.

blond-in-blue commented 1 year ago

If you’re attempting to run the server on ARM or Apple Silicon, try using lima to create a VM and set arch: x86_64 with bridged networking. Docker for M1 uses user-level QEMU emulation, which is faster but not as accurate as system-level QEMU emulation. I was able to get it to work on my M1 mini this way.

hyunjaekim commented 1 year ago

So you set linux VM using lima and install docker in it then run this image. Is that right?

blond-in-blue commented 1 year ago

So you set linux VM using lima and install docker in it then run this image. Is that right?

Yes, with a few modifications by mixing the docker and vmnet example yamls. At the bottom is the manifest I used to initiate the VM. Change disk, cpus, and memory to whatever you'd like. The important additions are arch: "x86_64" which enables system-level (slow but accurate) QEMU emulation instead of user-level (fast but inaccurate) QEMU emulation and networks: - lima: bridged. Note: bridged networking will create a separate hostname (lima-.lan), so this method isn't possible via a cloud service, and you will need to forward the ports on your router from that IP instead of your host machine's IP. You may be able to do this without bridged networking by forwarding your ports from the VM/host a different way, but that's the easiest way of being able to forward UDP ports.

As mentioned in the docs, before initialising the VM, run:

# Install socket_vmnet
brew install socket_vmnet

# Set up the sudoers file for launching socket_vmnet from Lima
limactl sudoers >etc_sudoers.d_lima
sudo install -o root etc_sudoers.d_lima /etc/sudoers.d/lima

Using the below template, run limactl start --name=valheim-server ./valheim-server.yaml, run the docker image, then forward your ports and wait for it to connect.

# valheim-server.yaml

arch: "x86_64"
disk: 30GiB
cpus: 4
memory: 6GB

networks:
- lima: bridged

# To run `docker` on the host (assumes docker-cli is installed):
# $ export DOCKER_HOST=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock')
# $ docker ...

# This example requires Lima v0.8.0 or later
images:
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
- location: "https://cloud-images.ubuntu.com/releases/22.04/release-20221201/ubuntu-22.04-server-cloudimg-amd64.img"
  arch: "x86_64"
  digest: "sha256:8a814737df484d9e2f4cb2c04c91629aea2fced6799fc36f77376f0da91dba65"
- location: "https://cloud-images.ubuntu.com/releases/22.04/release-20221201/ubuntu-22.04-server-cloudimg-arm64.img"
  arch: "aarch64"
  digest: "sha256:8a0477adcbdadefd58ae5c0625b53bbe618aedfe69983b824da8d02be0a8c961"
# Fallback to the latest release image.
# Hint: run `limactl prune` to invalidate the cache
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img"
  arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-arm64.img"
  arch: "aarch64"

mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true
# containerd is managed by Docker, not by Lima, so the values are set to false here.
containerd:
  system: false
  user: false
provision:
- mode: system
  # This script defines the host.docker.internal hostname when hostResolver is disabled.
  # It is also needed for lima 0.8.2 and earlier, which does not support hostResolver.hosts.
  # Names defined in /etc/hosts inside the VM are not resolved inside containers when
  # using the hostResolver; use hostResolver.hosts instead (requires lima 0.8.3 or later).
  script: |
    #!/bin/sh
    sed -i 's/host.lima.internal.*/host.lima.internal host.docker.internal/' /etc/hosts
- mode: system
  script: |
    #!/bin/bash
    set -eux -o pipefail
    command -v docker >/dev/null 2>&1 && exit 0
    export DEBIAN_FRONTEND=noninteractive
    curl -fsSL https://get.docker.com | sh
    # NOTE: you may remove the lines below, if you prefer to use rootful docker, not rootless
    systemctl disable --now docker
    apt-get install -y uidmap dbus-user-session
- mode: user
  script: |
    #!/bin/bash
    set -eux -o pipefail
    systemctl --user start dbus
    dockerd-rootless-setuptool.sh install
    docker context use rootless
probes:
- script: |
    #!/bin/bash
    set -eux -o pipefail
    if ! timeout 30s bash -c "until command -v docker >/dev/null 2>&1; do sleep 3; done"; then
      echo >&2 "docker is not installed yet"
      exit 1
    fi
    if ! timeout 30s bash -c "until pgrep rootlesskit; do sleep 3; done"; then
      echo >&2 "rootlesskit (used by rootless docker) is not running"
      exit 1
    fi
  hint: See "/var/log/cloud-init-output.log". in the guest
hostResolver:
  # hostResolver.hosts requires lima 0.8.3 or later. Names defined here will also
  # resolve inside containers, and not just inside the VM itself.
  hosts:
    host.docker.internal: host.lima.internal
portForwards:
- guestSocket: "/run/user/{{.UID}}/docker.sock"
  hostSocket: "{{.Dir}}/sock/docker.sock"
message: |
  To run `docker` on the host (assumes docker-cli is installed), run the following commands:
  ------
  docker context create lima-{{.Name}} --docker "host=unix://{{.Dir}}/sock/docker.sock"
  docker context use lima-{{.Name}}
  docker run hello-world
  ------