joedwards32 / CS2

CS2 Dedicated Server Docker Image
https://hub.docker.com/r/joedwards32/cs2
MIT License
299 stars 55 forks source link

Can't access server externally, even with port forwarding #51

Closed xt9 closed 1 year ago

xt9 commented 1 year ago

I've set up the server with docker compose, and can access it locally.

Some sanity checks I've done:

  1. Made sure sv_lan 0 was properly emplaced into the server.cfg
  2. Added +sv_setsteamaccount 144xxxxxxxxxxxxxxxxxxxxxxxxxxxxx in addition to the steam login credentials
  3. Verified port forwarding I set up in my router on 27015 via https://portchecker.co/check-it
  4. Verified logs look reasonable

firefox_iAKM7lX5d3

Relevant log excerpt

cs2-dedicated  | SV:  Spawn Server: de_inferno
cs2-dedicated  | CNetworkGameServerBase::SetServerState (ss_waitingforgamesessionmanifest -> ss_loading)
cs2-dedicated  | Got SDR network config.  Loaded revision 1699039286 OK
cs2-dedicated  | SDR RelayNetworkStatus:  avail=Not Attempted  config=OK  anyrelay=Not Attempted   (No need for SDR client network access)
cs2-dedicated  | SV:  Connection to Steam servers successful.
cs2-dedicated  | SV:  ServerSteamID=[G:1:10430232] (85568392930469656).
cs2-dedicated  | [STARTUP] {4.195} logged on to Steam
cs2-dedicated  | Gameserver logged on to Steam, assigned identity steamid:85568392930469656
cs2-dedicated  | AuthStatus (steamid:85568392930469656):  Attempting  (Requesting cert)
cs2-dedicated  | Set SteamNetworkingSockets P2P_STUN_ServerList to '155.133.252.39:3478' as per SteamNetworkingSocketsSerialized
cs2-dedicated  | CWorldRendererMgr::ServiceWorldRequests long frame: 47.421157ms
cs2-dedicated  | SV:  VAC secure mode is activated.
cs2-dedicated  | AuthStatus (steamid:85568392930469656):  OK  (OK)
cs2-dedicated  | Certificate expires in 48h00m at 1699270933 (current time 1699098132), will renew in 46h00m
cs2-dedicated  | GC Connection established for server version 2000185, instance idx 1
cs2-dedicated  | [STARTUP] {4.598} activated session on GC
cs2-dedicated  | Failed loading resource "maps/prefabs/misc/terrorist_team_intro_variant2/world_visibility.vvis_c" (ERROR_FILEOPEN: File not found)
cs2-dedicated  | CNetworkGameServerBase::SetServerState (ss_loading -> ss_active)

In the CS2 client I get the following with connecting with connect 81.234.152.164:27015; password xxxxxx;


[NetSteamConn] Steam Net connection #740075167 pipe closed by peer, reason 2055: NETWORK_DISCONNECT_LOOPDEACTIVATE
[NetSteamConn] CloseSteamNetConnection handle #740075167 (userdata -1)
[NetSteamConn] Opened Steam Net Connection on socket 'client' to 81.234.152.164:27015, connection #2374629985 UDP invalid@81.234.152.164:27015
[Networking] Created poll group for socket 'client'
[Developer] Success.
[SteamNetSockets] [#2374629985 UDP invalid@81.234.152.164:27015] problem detected locally (5003): Timed out attempting to connect
[NetSteamConn] Steam Net connection #2374629985 UDP invalid@81.234.152.164:27015 problem detected locally, reason 5003: Timed out attempting to connect
[Client] Failed to connect to 81.234.152.164:27015.  Reason code 5003.  Timed out attempting to connect
[Client] CL:  Server disconnected: 72: NETWORK_DISCONNECT_CONNECT_REQUEST_TIMEDOUT
**** Unable to localize '#GenericConfirmText_Label' on panel descendant of 'PopupManager'
[NetSteamConn] Closing Steam Net Connection on socket 'client' to 81.234.152.164:27015, handle #2374629985 (1000 CloseSocket)
[NetSteamConn] CloseSteamNetConnection handle #2374629985 (userdata -1)
[Networking] Summary of connection [#2374629985 UDP invalid@81.234.152.164:27015]:
[Networking]     End-to-end connection: closed due to problem detected locally, reason code 5003.  (Timed out attempting to connect)
[Networking]         Current rates:
[Networking]             Sent:   0.0 pkts/sec   0.0 K/sec
[Networking]             Recv:   0.0 pkts/sec   0.0 K/sec
[Networking]             Ping:2ms    Max latency variance: ???ms
[Networking]             Est avail bandwidth: 256.0KB/s  
[Networking]             Bytes buffered: 0
[Networking]         Lifetime stats:
[Networking]             Totals
[Networking]                 Sent:         22 pkts          11,083 bytes
[Networking]                 Recv:          1 pkts              26 bytes
[Networking]             No ping distribution available.  (1 samples)
[Networking]             No connection quality distribution available.  (0 measurement intervals)
[Networking]             Latency variance histogram not available
[Networking]         No rate stats received from remote host
[Networking]         No lifetime stats received from remote host
[Networking]     
[NetSteamConn] Removing Steam Net Connection for 81.234.152.164:27015, handle #2374629985
[Networking] Closing 'client' poll group

I've tried googling the UDP invalid error but not found much. Right now I left - CS2_IP= empty in docker-compose because I seemingly get other errors when i set it to 0.0.0.0

Advice would be much appreciated

joedwards32 commented 1 year ago

If you can access the container internally but not externally that you have a router/firewall configuration problem, not a problem with the container.

Your external port check looks like a TCP check, but the CS2 game protocol runs over UDP.

I recommend you double check your Router/Firewall configuration to ensure that you are forwarding UDP traffic to your container.

Some devices will let you create a single tcp_udp rule, others will require two separate rules.

xt9 commented 1 year ago

I think the port forward is set up correctly but my guess is that it's wsl2 network shenanigans making it so the traffic is not ending up in the right place. Stumbled into this gigantic wsl thread https://github.com/microsoft/WSL/issues/4150 which seems to explain why connecting locally works, but external traffic not being router correctly.

xt9 commented 1 year ago

Got it working on ubuntu, but my method from the start was connecting to the external ip for my network from a client running cs2 on the same network, and that for some reason does not work. But when I asked a friend to connect to my external ip it worked.