jsknnr / enshrouded-server

Run Enshrouded dedicated server in a container
MIT License
183 stars 21 forks source link

Unable to join the server #16

Closed wehmoen closed 7 months ago

wehmoen commented 7 months ago

I setup the server using the command from your example. Checking the logs I see:

[Session] 'HostOnline' (up)!
[Session] finished transition from 'Lobby' to 'Host_Online' (current='Host_Online')!

Then when I connect I get into a loading screen and after some time I get thrown back to the main menu. Game shows "Joining game failed"

The docker logs show this:

[online] Session accepted with peer ( id 76561198083236349 ).
[online] Added Peer #0.
[online] Session failed for peer #0 with error 4.
[online] Removed Peer #0.

Any idea what this error 4 means?

Started the game using Steam normally.

eschack commented 7 months ago

I get the exact same error when attempting to connect to my server.

It is running as a Docker container on a Hetzner dedicated server (Ubuntu 22.04).

Kalanur commented 7 months ago

Try 127.0.0.1 in the server config instead of 0.0.0.0. Fixed it for me but on Windows. Maybe it helps

jsknnr commented 7 months ago

No idea what error 4 means. The game engine is custom built by the developers and errors don't seem to be documented. If you are unable to join, but you see your server on your list, there is likely an issue with your router and or firewall. You need to make sure the ports are open on both your server and your router and you will also likely have to port forward the game port and the steam query port from your router to the private IP address of your server. Connectivity issues are not an issue with the image but I am happy to attempt some basic debug help.

Yannick183 commented 7 months ago

Try 127.0.0.1 in the server config instead of 0.0.0.0. Fixed it for me but on Windows. Maybe it helps

That's what fixed it for me as well running on a linux host

wehmoen commented 7 months ago

I should have mentioned that I am using a dedicated server with static IP. For testing purposes I reinstalled it with Debian 12 and disabled the firewall entirely. Unfortunately with the same result. I ended up installing Windows Server 22 🥲. On there I installed the server via steam and run it as a Service. That works fine. Hopefully the game devs will make it easier to run on Linux in future updates. Oh and on Windows all I had to do apart from the installation was creating a simple firewall rule for the udp ports.

eschack commented 7 months ago

I finally got it to work in a Docker container on my Hetzner dedicated server host running Ubuntu 22.04 by

I doubt all of the above things are necessary, but it is working for me now.

MrSnake0208 commented 7 months ago

I finally got it to work in a Docker container on my Hetzner dedicated server host running Ubuntu 22.04 by

  • setting the Docker containers network_mode to "host"
  • putting the servers public static IP address in the "IP" field in enshrouded_server.json
  • ensuring that incoming traffic on ports 15636-15637 and 27015-27036 (both TCP and UDP) are allowed through the firewall

I doubt all of the above things are necessary, but it is working for me now.

Sorry, but when i putting the servers public static IP address in the "IP" field in enshrouded_server.json, it display Server failed to connected to Steam 3 and start failed

eschack commented 7 months ago

Sorry, but when i putting the servers public static IP address in the "IP" field in enshrouded_server.json, it display Server failed to connected to Steam 3 and start failed

I am guessing the "IP" setting is so the Enshrouded server knows what specific network interface to listen on. So if it does not work for you I suspect you might be behind NAT, or are not running the container in host network mode.

If you are behind NAT you would set the "IP" setting to that of the local network interface facing the router, and in the router you would also need to open and forward the necessary ports to that IP.

cstruck commented 7 months ago

there seems to be more to it, when running on linux and you have more than 1 IP address on the same interface, after the server discovery the game will try it with the first address on the interface event if thats not the IP with the default gateway configured.

I had on the client side 3 IPs on the Interface 10.x.x.x, 172.x.x and my 192.168.x.x which has the default route. For the discovery it used the correct one 192.168.x.x but afterwards it took the one with the lowest-ip 10.x.x.x after I removed that from the interface it took the 172.x.x, and only after I removed that IP I could connect with the correct IP to the server.

Secondly the server seems to use for the game connection a random high port in my case for the first connection this was something 50kish, for the second one 46kish. so I had to open UDP highports on the server side for the game to correctly connect without the Session failed for peer #0 with error 4 error.

bvehse commented 7 months ago

I can support @cstruck's observation regarding ports. Inbound the documented ports 15636/UDP and 15637/UDP are sufficient, but outgoing a wide range of random UDP ports has to be allowed. After realising this Session failed for peer #0 with error 4 was finally solved and everything works great.

alex-morgun commented 7 months ago

Actually a see no traffic except 15637/UDP, everything works.

lsruan commented 7 months ago

I finally got it to work in a Docker container on my Hetzner dedicated server host running Ubuntu 22.04 by

  • setting the Docker containers network_mode to "host"
  • putting the servers public static IP address in the "IP" field in enshrouded_server.json
  • ensuring that incoming traffic on ports 15636-15637 and 27015-27036 (both TCP and UDP) are allowed through the firewall

I doubt all of the above things are necessary, but it is working for me now.

@eschack, how to set network_mode to "host" using docker-compose?

stavroguine commented 6 months ago

For those running into this issue, I manage to solve it by only setting "host" to network_mode inside my compose file :

services:
  enshrouded:
    image: sknnr/enshrouded-dedicated-server:v2.0.5
    network_mode: host

Now I can join the server without error 4.

zsamboky commented 4 months ago

When you combine network_mode: "host" with an application binding to 0.0.0.0, and removing the GAME_PORT & QUERY_PORT, you're setting up a scenario where the application listens on all network interfaces of the host machine itself. Here’s my compose.yaml file:

services:
  enshrouded:
    image: sknnr/enshrouded-dedicated-server:v2.0.5
    network_mode: "host"
    environment:
      - SERVER_NAME=Name Of Your Awesome Server
      - SERVER_PASSWORD=password
      - GAME_PORT=15636
      - QUERY_PORT=15637
      - SERVER_SLOTS=16
      - SERVER_IP=0.0.0.0
    volumes:
      - enshrouded-persistent-data:/home/steam/enshrouded/savegame

volumes:
  enshrouded-persistent-data:

Using the above, one can connect to your awesome server using <your machine's IP address>:15637

If there is a better way that works, please let me know.