arkmanager / ark-server-tools

Set of server tools used to manage ARK: Survival Evolved servers on Linux
MIT License
677 stars 143 forks source link

"arkmanager status" problem, server always offline ? #135

Closed pixmaip closed 8 years ago

pixmaip commented 8 years ago

Hi,

I recently used ark-server-tools to create a ARK server on my Ubuntu 15.04 server. After following the tutorial correctly (increasing the ulimit etc ...), I now face a problem that I am not able to solve after hours working on it.

When I execute the command arkmanager status from the user running the server (here steam), I get this :


steam@ns351403:/var/log/arktools$ arkmanager status Server running: Yes Server online: No Server version: 708279


For information, I already waited more that 15 minutes (and even once a whole night in case the server had problems binding with steam servers and I got the same output.

After this, I interrested myself in where this "No" comes from. In the arkmanager file, at line 188, we have the function "isTheServerUp()" which executes the command:


lsof -i :"$ark_Port"


The port of my ARK server is 7778 so the full command executed is:


lsof -i :7778


If the output is empty, the server not online and if there is an output, it means that the server is online. When I execute this command as the steam user, the output is indeed, empty. So it confirms the No of the arkmanager status command. But the thing is that when I execute the command as the root user (or when I execute the command with the steam user with sudo), the output of the command is:


root@ns351403:~# lsof -i :7778 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ShooterGa 6980 steam 126u IPv4 31693433 0t0 UDP *:7778


So, it means that the server is indeed online ! What I don't understand in the story, is that even with all this, the server doesn't appear in any lists.

What did I do wrong ? What are the possible causes of the problem and why does the output of the lsof command depends on the user executing it ?

Thanks, Pixmaip

klightspeed commented 8 years ago

Are you running the server using arkmanager start or using the init script? Do you have selinux installed?

Does running netstat -lntup as the user list UDP ports 7778 and 27026, and TCP port 32330? It sounds like Ubuntu has turned on the "security" feature in lsof that has it list only files and ports opened by processes running as the user invoking the lsof command.

Is this running behind a home gateway or on a cloud server? Have UDP ports 7778 and 27026 been forwarded on the gateway, and have those ports been allowed in your iptables rules?

pixmaip commented 8 years ago

To start the server, I use arkmanager start, SELinux is not installed on the server.

The output netstat -lntup ran as steam:


steam@ns351403:~$ netstat -lntup Connexions Internet actives (seulement serveurs) Proto Recv-Q Send-Q Adresse locale Adresse distante Etat PID/Program name /proc/net/tcp: Permission non accordée (the french of "Permission denied")


When I run it as root (same output as steam in sudo), it lists 7778, 27016 and 32330 (TCP)

Also, I am not running the server behind any gateway. This is a simple dedicated server.

For the ports, I allowed 7778, 27016 (like in your tutorial) and 32330 but not 27026 (I just did and it doesn't affect the problem)

Thanks, Pixmaip

klightspeed commented 8 years ago

The permission denied error says that your kernel has a patch applied to it that makes /proc/net/tcp (and likely other /proc/net entries) readable only by root. The kernel that comes with Ubuntu 15.04 does not have this patch, so you must be using a custom kernel (possibly supplied by your VM host).

In your case, I think the only way to work around this would be to move the server query out of the isTheServerUp if/then/else/fi block.

pixmaip commented 8 years ago

This is indeed a custom kernel (by OVH if you want to know).

If the server query doesn't work, this is not a real problem for me (I can create a script using the same code that can be run as root).

The real problem is that the server, even after hours running, doesn't show up in any lists and is completely unjoinable by any players.

Is this linked with this security feature added by the custom kernel ? Or could my configuration of the server be wrong ?

Thanks,

klightspeed commented 8 years ago

Check that any firewalls between your server and the public internet allow connections to the UDP server ports (ark_Port and ark_QueryPort) and that they allow related/established connections. It is not necessary to allow external connections to your RCON port, and I would suggest not permitting external connections to that port.

pixmaip commented 8 years ago

I double checked that all ARK server ports are allowed on the firewall (for me 7778, 27016 and 32330). But when the server is running, I still get a connection refused while connecting on one of those ports (using canyouseeme.org for example). It is like the server is indeed running but isn't able to reach public internet, for whatever reason.

klightspeed commented 8 years ago

canyouseeme.org will get connection refused on ports 7778 and 27016 because it is checking TCP ports, while the server uses UDP ports.

The following perl script (when provided with ip and port as arguments - e.g. perl ./query.pl 1.2.3.4 27016) should query the server (with a 1 second timeout) when run from e.g. your computer:

#!/usr/bin/perl
my $ip = $ARGV[0];
my $port = int($ARGV[1]);
socket(my $socket, PF_INET, SOCK_DGRAM, 0);
setsockopt($socket, SOL_SOCKET, SO_RCVTIMEO, pack("i4", 1, 0, 0, 0));
my $sockaddr = pack_sockaddr_in($port, inet_aton($ip));
send($socket, "\xff\xff\xff\xffTSource Engine Query\x00", 0, $sockaddr);
my $data = "";
recv($socket, $data, 1400, 0) or (print "Unable to query server\n" and exit(1));
my ($servername, $mapname, $game, $fullname, $rest) = split(/\x00/, substr($data, 6), 5);
my $players = ord(substr($rest, 2, 1));
my $maxplayers = ord(substr($rest, 3, 1));
print "Server Name: $servername\n";
print "Players: $players / $maxplayers\n";

If your firewall has a -j REJECT rule that covers port 32330, then this would give you a connection refused on that port.

pixmaip commented 8 years ago

The script returned a positive output (no player connected and server up) and, I absolutely don't know why, the server started showing up in lists ! A friend was able to connect and play.

Thanks you very much for the help, the problem is now solved.

klightspeed commented 8 years ago

It sounds like you ran into a problem that a few other people have seen, where for reasons unknown it either doesn't show up on the ARK server list or is one of the last servers to be queried for the server list.

Atriusftw commented 8 years ago

I think we'll just blame it on steam query network. It's been unstable lately.