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.93k stars 272 forks source link

Connection dropped after update to 0.147.3 #140

Closed darthf1 closed 3 years ago

darthf1 commented 3 years ago

Hi! Thanks for creating this docker file.

After the update to 0.147.3 this morning me and my friends are having difficulties joining the server.

In the thread below, there are some words about settings the -public flag to 1 as a starting argument. In my config I have the SERVER_PUBLIC ENV var to true. https://www.reddit.com/r/valheim/comments/lvynix/patch_notes_for_01473/

03/02/2021 16:31:24: Game server connected
03/02/2021 16:32:38: Got status changed msg k_ESteamNetworkingConnectionState_Connecting
03/02/2021 16:32:38: New connection
03/02/2021 16:32:38: Accepting connection k_EResultOK
03/02/2021 16:32:38: Connecting to Steamworks.SteamNetworkingIdentity
03/02/2021 16:32:38: Got status changed msg k_ESteamNetworkingConnectionState_Connected
03/02/2021 16:32:38: Connected
03/02/2021 16:32:38: Got connection SteamID <ID>
03/02/2021 16:32:38: Got handshake from client <ID>
03/02/2021 16:33:19: Got status changed msg k_ESteamNetworkingConnectionState_ProblemDetectedLocally
03/02/2021 16:33:19: Got problem 5003:Connection dropped
03/02/2021 16:33:19:   Closing socket <ID>
03/02/2021 16:33:19: Closing socket <ID>
03/02/2021 16:33:19:   send queue size:0
lloesche commented 3 years ago

Setting SERVER_PUBLIC=true will result in -public 1. See: https://github.com/lloesche/valheim-server-docker/blob/b62ce592fe49b2c76f5742c3e2ea3677dbc226da/defaults#L12-L14

InB4DevOps commented 3 years ago

Make sure you have port 2455 forwarded to your server. An unknown change in the recent update requires this port in addition to the other ports.

MapleBZH commented 3 years ago

Hi, can't see my server on steam since update (works fine before) even with port 2455 open, it's not a public server ! Installed on a synology NAS with docker any help ? all is fine in log...

EDIT : works fine with join IP on port 2456 (no need port 2455)

anacierdem commented 3 years ago

I seem to have a similar issue although I'm not sure on how can I access the server logs?

lloesche commented 3 years ago

@InB4DevOps I don't see port 2455 being used

udp        0      0 0.0.0.0:2457            0.0.0.0:*
udp6       0      0 :::2456                 :::*

Using latest Valheim and V+

03/02/2021 18:19:29: VERSION check their:0.147.3@0.9  mine:0.147.3@0.9

But I also don't see any disconnects. 🤔

InB4DevOps commented 3 years ago

I have no idea how this relates to server being connectable but only after I forwarded 2455 my friends could join my server. Before that I had the same problems as anyone else.

DailytheNoob commented 3 years ago

I seem to have a similar issue although I'm not sure on how can I access the server logs?

attach to the container while its running to see the console output

hate that you can't detach from docker containers after you attach to them cause the defaults are incredibly stupid? Threw together a thing to fix it add this to your bashrc and connect with dockat [container name]:

dockat () {
  dockid=$(docker ps -aqf "name=^$1$");
  docker attach --sig-proxy=false $dockid;
}

alias dockat=dockat
lloesche commented 3 years ago

I seem to have a similar issue although I'm not sure on how can I access the server logs?

docker logs valheim-server (or whatever --name you supplied in your run command) docker logs -f will tail the growing logs.

x1a0 commented 3 years ago

@lloesche Are you connecting thru NAT? I got disconnected if go thru NAT but if I use LAN IP to connect directly it works...

sisu4u commented 3 years ago

We experience the same running the server on kubernetes using a NodePort service. We've opened 2455 but it does not resolve the problem.

Also IP vs domain makes no difference.

What did work for us was setting hostNetwork: true which opens the ports directly avoiding the NodePort service

lloesche commented 3 years ago

@x1a0 depends on which layer you mean. I'm not using NAT to connect through some gateway or firewall to the container host. But Docker on the container host itself is using dnat to reach the correct ports. As in I'm not using host networking.

Like I wrote in #141 I would check what the UDP conntrack timeouts look like on the host. I.e. net.netfilter.nf_conntrack_udp_timeout and net.netfilter.nf_conntrack_udp_timeout_stream. And try setting them to something like 20 minutes (1200). Maybe the Valheim devs in an attempt to lower network traffic have done a change that makes the connection be idle for longer periods of time and now you're running into the default timeout of 30 seconds.

rollinscm commented 3 years ago

HI lloesche, First off, thank you for putting in the work to make running a server on a NAS an actual thing! Things were working great until the update today. I redownloaded your image and set up the server again with all of the ENV settings. I'm still getting a "disconnected" screen when trying to get in. I've done everything mentioned above except for the UDP conntrack timeout. Not sure how to do that. Is there a link to video that explains how to check those?

lloesche commented 3 years ago

@rollinscm so this is all for the Linux shell:

To check current values:

$ sudo sysctl net.netfilter | grep udp_timeout
net.netfilter.nf_conntrack_udp_timeout = 30
net.netfilter.nf_conntrack_udp_timeout_stream = 120

To set higher values:

$ sudo sysctl -w net.netfilter.nf_conntrack_udp_timeout=180
$ sudo sysctl -w net.netfilter.nf_conntrack_udp_timeout_stream=1200

see if that makes a difference.

Alternatively you can run the container in host networking mode and thereby work around any NAT timeouts.

If you're on a Synology NAS you can set this option here: image

rollinscm commented 3 years ago

@lloesche Thank you for that info. I ended up having my brother try to log onto the server that I have here at my place. He's able to get into the game while I'm not. Looked up this bug online and it seems like multiple people are having problems. Guess it's not just me or anything. Here's a link to the article. https://www.pcgamesn.com/valheim/dedicated-server-disconnected

lloesche commented 3 years ago

@rollinscm thanks! Well it seems to be such a widespread issue that I'm sure the devs will provide a patch soon. Your server will auto update when that happens and all should be good. The game has been running so well for me that I sometimes forget it isn't even released yet.

CCA282 commented 3 years ago

Hi, I have the same issue every Update and restarting the image fixes the problem.

anacierdem commented 3 years ago

I'm on a Windows machine and the issue seems unrelated to the docker container indeed. Tried starting the win executable shipped via steam and it is having the same issue as well. Upon checking container logs, I can say that it properly starts the server but somehow it is not accepting connections. Opening new ports didn't solve the issue for me.

@CCA282 I also have the same problem. The docker used to need a restart once in a while (I am also suspecting the updates). This is not related to the current issue and must be fixed though. I'll try to post logs for when it happens.

anacierdem commented 3 years ago

Upon investigating further and seeing that the devs removed the steam layer, I realized that my server was running ok. Not seeing it in the steam's server list, I was assuming it was not being responsive but that's not the case. The game client can successfully connect when provided with the ip:port. I'll try to follow up with the container getting unresponsive problem if I have it again in the future.

rollinscm commented 3 years ago

@lloesche New update! So my PC and my Synology NAS are both hardwired into the same router. When I use my VPN on my PC, I can play Valheim on the container, but when I don’t, then yea the disconnected error happens. Seems like the error on Iron Gates end is that if your WAN IP address on your PC is the same as the NAS, then you won’t be able to join into the server.

anacierdem commented 3 years ago

@rollinscm Might not be a bug but a feature :) seems like the Rejected request from RFC1918 IP to public server address error thrown by some routers when you try to connect to it with the external ip. Maybe your NAS is dropping packets when a similar thing happens? I have no issues connecting with the external ip (though docker is on the same computer) Feels like a NAS issue to me, maybe there is a setting?

CSmith-T-Plan commented 3 years ago

This is happening for me too - it appears to be related to being behind a NAT router; I can connect on the local network just fine, but players outside cannot connect through my external IP. Fingers crossed the devs solve it quickly!

beltet commented 3 years ago

This is happening for me too - it appears to be related to being behind a NAT router; I can connect on the local network just fine, but players outside cannot connect through my external IP. Fingers crossed the devs solve it quickly!

I have the opposite problem. I can't connect when I'm inside my network. But when I use my VPN I have no problem at all to connect to the server. I believe that with the new DNS update, it broke something there. Not certain what though...

lloesche commented 3 years ago

Closing this as there's nothing that can be done inside the container.