• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved [NICAW AAC] Avesta - Online status problem

Tony32

Veteran OT User
Joined
Jun 6, 2008
Messages
1,269
Reaction score
353
Hello Otland!

I am running nicaw aac for avesta on linux running an avesta distro.
All ports are open, server works just fine. Create accs, chars and guilds also work perfectly. Server listens to port 7171.
Nicaw config is 127.0.0.1 and port 7171 for status.

So now to my problem, the server status says my server is offline, aldoh, sometimes, when I for example re-save the config or login to the server it shows online status, but as soon as I reload the page or go to another page, it says server offline again.

My status.php file
Code:
<?php 
include ('config.inc.php');
function getinfo($host='localhost',$port=7171){
		// connects to server
        $socket = @fsockopen($host, $port, $errorCode, $errorString, 1);
		$data = '';
        // if connected then checking statistics
        if($socket)
        {
            // sets 1 second timeout for reading and writing
            stream_set_timeout($socket, 1);

            // sends packet with request
            // 06 - length of packet, 255, 255 is the comamnd identifier, 'info' is a request
            fwrite($socket, chr(6).chr(0).chr(255).chr(255).'info');

            // reads respond
			while (!feof($socket)){
				$data .= fread($socket, 128);
			}

			// closing connection to current server
			fclose($socket);
		}
	return $data;
}
if ($cfg['status_update_interval'] < 60) $cfg['status_update_interval'] = 60;
$modtime = filemtime('status.xml');
if (time() - $modtime > $cfg['status_update_interval'] || $modtime > time()){
	$info = getinfo($cfg['server_ip'], $cfg['server_port']);
	if (!empty($info)) file_put_contents('status.xml',$info);
}else $info = file_get_contents('status.xml');
if (!empty($info)) {
$infoXML = simplexml_load_string($info);

	$up = (int)$infoXML->serverinfo['uptime'];
	$online = (int)$infoXML->players['online'];
	$max = (int)$infoXML->players['max'];

	$h = floor($up/3600);
	$up = $up - $h*3600;
	$m = floor($up/60);
	$up = $up - $m*60;
	if ($h < 10) {$h = "0".$h;}
	if ($m < 10) {$m = "0".$m;}
	echo "<span class=\"online\">Server Online</span><br/>\n";
	echo "<span class=\"players\">Players: <b>$online/$max</b></span><br/>\n";
	//echo "<span class=\"monsters\">Monsters: <b>".$infoXML->monsters['total']."</b></span><br/>\n";
	echo "<span class=\"uptime\">Uptime: <b>$h:$m</b></span><br/>\n";
} else {
	echo "<span class=\"offline\">Server Offline</span>\n";
}
?>

Thanks in advance.

- - - Updated - - -

The problem doesnt seem to be the connetion between the server and the webserver, I think it's something wrong with the script itself. The script only updates via Ajax what it seems.
Code:
<script type="text/javascript">
//<![CDATA[
    new Ajax.PeriodicalUpdater('server_state', 'status.php', {
      method: 'get', frequency: 60, decay: 1
    });
//]]>
</script>

And not on every page reload. Anyone with good php knowlege can make it refresh on each page?

Solved! - The problem was, my orginal config was missing "StatusTimeout = 1" setting. Now when I added it, it works. Thanks for your help!
 
Last edited:
try this.

Code:
<?php
include ('config.inc.php');
function getinfo($host='localhost',$port=7171){
		// connects to server
        $socket = @fsockopen($host, $port, $errorCode, $errorString, 1);
		$data = '';
        // if connected then checking statistics
        if($socket)
        {
            // sets 1 second timeout for reading and writing
            stream_set_timeout($socket, 1);

            // sends packet with request
            // 06 - length of packet, 255, 255 is the comamnd identifier, 'info' is a request
            fwrite($socket, chr(6).chr(0).chr(255).chr(255).'info');

            // reads respond
			while (!feof($socket)){
				$data .= fread($socket, 128);
			}

			// closing connection to current server
			fclose($socket);
		}
	return $data;
}
if ($cfg['status_update_interval'] < 60) $cfg['status_update_interval'] = 60;
$modtime = filemtime('status.xml');
if (time() - $modtime > $cfg['status_update_interval'] || $modtime > time()){
	$info = getinfo($cfg['server_ip'], $cfg['server_port']);
	if (!empty($info)) file_put_contents('status.xml',$info);
}else $info = file_get_contents('status.xml');
if (!empty($info)) {
$infoXML = simplexml_load_string($info);

	$up = (int)$infoXML->serverinfo['uptime'];
	$online = (int)$infoXML->players['online'];
	$max = (int)$infoXML->players['max'];

	$h = floor($up/3600);
	$up = $up - $h*3600;
	$m = floor($up/60);
	$up = $up - $m*60;
	if ($h < 10) {$h = "0".$h;}
	if ($m < 10) {$m = "0".$m;}
	echo "<span class=\"online\">Online</span><br/>\n";
	echo "<span class=\"players\">Players: <b>$online/$max</b></span><br/>\n";
	//echo "<span class=\"monsters\">Monsters: <b>".$infoXML->monsters['total']."</b></span><br/>\n";
	echo "<span class=\"uptime\">Uptime: <b>$h:$m</b></span><br/>\n";
} else {
	echo "<span class=\"offline\">Offline</span>\n";
}
?>
 
Nope, says it's offline. Very weird. It's probably something wrong with my server, I have no idea why doh :/

EDIT: Got it working now when I used another config lua file from another server, that's odd. As the ip configs and ports are the same, wtf?

EDIT2: Solved! - The problem was, my orginal config was missing "StatusTimeout = 1" setting. Now when I added it, it works. Thanks for your help!
 
Last edited:
Back
Top