garrysmod-issues
garrysmod-issues copied to clipboard
Problems with GMod client connecting to servers on local network
Problem
I'm running a GMod dedicated server in a Docker container and for the past few days, I had no idea why I couldn't connect. I've bound the ports to the right locations, tested other peoples docker images and still the same result. The server would start and do everything as expected if I was running it out side of a container and reaching:
VAC secure mode is activated.
That was a good sign, I got everything working in my custom image, run status with these settings:
/server/srcds_run -game garrysmod -console
hostname: Garry's Mod
version : 2019.11.12/24 7706 secure
udp/ip : x.x.x.x:27015 (public ip: x.x.x.x)
map : gm_construct at: 0 x, 0 y, 0 z
players : 0 (128 max)
So I can confirm the server is working in container.
I then boot up the Gmod client and I can't connect. Strange.
I then installed the windows Gmod dedicated server (something I wanted to avoid) and run it on the same port as the docker container. But now I can then the windows server.
Here's where the issue lies, I thought it was a problem with how Docker/my network is setup but what I tried and some how worked was; connect to the windows server, disconnect, shut down the windows server, boot the docker container, and NOW i can connect. This seems to be a bug with the Gmod client and it had been driving me crazy.
Reproduction
- Run a gmod server in a Docker container binding the udp/tcp port of 27015 - here's an image I've tested that I encounter with the same problem: https://hub.docker.com/r/ceifa/gmod-server
- Boot the gmod client and attempt to connect using your local ipv4 address and port
- You shouldn't be able to connect, it should hang on "connecting to server"
The requested fix: Allow connection to this server
Workaround
- Boot the windows gmod server (SRCDS.exe), by using the interface (I didn't try with a start up script) with network set to
Lan - Boot gmod client
- Connect to the windows server
- Once in, disconnect but don't quit the gmod client or refresh the server list
- Stop the windows server
- Now, boot the docker container with the same ports bound
- You should now should be able to connect to the docker server
Summary
- Can't connect to Gmod server in docker, unless I boot a windows server to "trick" the client into allowing me to connect.
- The
connectconsole command doesn't work unless I've done the same trick above to allow me to connect - I think this is a client issue
Other
- Using Docker Desktop for Windows
- Gmod Client Version - 2020.1.25
- Windows Gmod Server Version:
version : 2019.11.12/24 7737 insecure - Docker Gmod Server Version:
version : 2019.11.12/24 7706 secure(taken from above) - This could have been an issue for a while, I have only just recently come back to Gmod.
Any other info needed lmk. I will continue to use the workaround until a fix, I hope someone can help me resolve the issue though.
I'm having a similar issue.
For me, i'm not running it on docker, but still running it locally on my computer. Could not connect to localhost or anything, but all my friends can join from the outside.
But, after I found this issue, I tried the workaround and it works for me.
Hope this issue gets fixed.
Are you trying to connect with localhost or 127.0.0.1 then its no bug its wanted to do that
and if your local ip is like 10.0.0.25 (Private network) it wont work too the only local ip that works is
(It getting printed in the console)
This still happens today. @Alig96's workaround still works too.
I only run gmod on my windows machine for development, so the workaround isn't too annoying. I created a small script to install and start the native gmod to make it a little easier for me in the future (change paths to something that makes sense for you):
install.ps1
New-Item -Force -Path "native-gmod\steamcmd" -ItemType Directory
New-Item -Force -Path "native-gmod\gmodserver" -ItemType Directory
# TODO: Only redownload if it doesn't already exist
Invoke-WebRequest -OutFile native-gmod\steamcmd\steamcmd.zip -Uri https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip
Expand-Archive -Path native-gmod\steamcmd\steamcmd.zip -DestinationPath native-gmod\steamcmd
native-gmod\steamcmd\steamcmd.exe +force_install_dir ..\gmodserver +login anonymous +app_update 4020 validate +quit
start.ps1
native-gmod\gmodserver\srcds.exe +maxplayers 20 -console +gamemode sandbox +map gm_construct +sv_setsteamaccount <GSLT TOKEN>
(GSLT Token can be created here https://steamcommunity.com/dev/managegameservers)
This is speculation on my part, but I doubt this has anything to do with the game. I would imagine whatever you are "tricking" is not the game client, but whatever is blocking the initial connection, such as some sort of firewall or something.
The game client itself doesn't just refuse to connect if the server is in a docker container or some other criteria is met. It's just not a thing.