K-4U / serverInfoProvider

http://minecraft.curseforge.com/mc-mods/serverinfoprovider
Other
1 stars 4 forks source link

SIP didn't return data most of the time #8

Open EphisPaF opened 7 years ago

EphisPaF commented 7 years ago

Hi,

I'm using the 3.0.33 version on my minecraft 1.12 server with forge. I'm working on a web site that provide server's info, but SIP didn't return data all the time. I reduce the amount of data send to only time but it still don't return all the time. Should I use an other build version ?

Infos about the server configuration : OS : Debian 9 JAVA : openjdk version "1.8.0_141" MC : 1.12 Forge : forge-1.12-14.21.1.2407-universal SIP : ServerInfoProvider-1.12-3.0.33-universal

You can get a view of the website here : http://brotopia.malus.me/ The source code from this website is inspired from this github : https://github.com/K-4U/SIP-web

Here is the display of 1 time working and 1 failure right after, with debug mode activated :

[14:02:24] [Listener #0/INFO] [sip]: SEND: {}
[14:02:42] [Listener #2/INFO] [sip]: New connection from /127.0.0.1:51242
[14:02:42] [Listener #2/INFO] [sip]: RECV: ["time"]
[14:02:42] [Listener #2/INFO] [sip]: SEND: {
  "time": {
    "0": "06:54"
  }
}
[14:02:51] [Listener #1/INFO] [sip]: New connection from /127.0.0.1:51244
[14:02:51] [Listener #1/INFO] [sip]: RECV: ["time"]
[14:02:51] [Listener #1/INFO] [sip]: SEND: {
  "time": {
    "0": "06:59"
  }
}
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]: java.net.SocketException: Broken pipe (Write failed)
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]:  at java.net.SocketOutputStream.socketWrite0(Native Method)
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]:  at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]:  at java.net.SocketOutputStream.write(SocketOutputStream.java:134)
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]:  at java.io.DataOutputStream.writeBytes(DataOutputStream.java:276)
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]:  at k4unl.minecraft.sip.network.TCPServerThread.lambda$run$0(TCPServerThread.java:73)
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]:  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]:  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]:  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]:  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]:  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]:  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[14:02:51] [Listener #1/INFO] [STDERR]: [k4unl.minecraft.sip.network.TCPServerThread:lambda$run$0:77]:  at java.lang.Thread.run(Thread.java:748)
K-4U commented 7 years ago

First of all: Thank you for providing all the info and even finding the debug option! This is how bug reports should go :)

I will have a look at the bug soon. Where you selecting the data automatically or actually refreshing every 10 seconds?

Did you modify any of my PHP code? or just the html/css?

EphisPaF commented 7 years ago

I do a manual refresh with [F5] key. I did modify your php code juste a little bit, here are the changes :

in SIPRequester.class.php rename as SIPRequester.php :

/**
 * Holds the returned values
 *
 * @var array
 */
public $returnedMap = [];

public function __construct() {
  //$this->server = $server;
  $this->server = '127.0.0.1';
  //$this->port = $port;
  $this->port = 25566;
}

adding some display in SIPRequester.doRequest() :

$result = socket_connect($socket, $this->server, $this->port);
echo 'socket result : '.$result;

And that's all the code I stole from you :p

I call the class like this in my page :

<?php
include_once 'functions/SIPRequester.php';
$requester = new SIPRequester();
$requester->addValueToRequest('time');
//$requester->addValueToRequest('weather');
//$requester->addValueToRequest('uptime');
//$requester->addValueToRequest('daynight');
//$requester->addValueToRequest('players', 'latestdeath');
//$requester->addValueToRequest('players', 'lastonline');
//$requester->addValueToRequest('deaths');
//$requester->addValueToRequest('tps');
//$requester->addValueToRequest('versions');
$requester->doRequest();
$players = $requester->getValue('players');
$deaths = $requester->getValue('deaths');

I write the result like you did on your example :

<div>
  <div><div class="toprow"><span>Heure</span><span><?= $requester->getValue('time')[0] ?></span></div></div>
  <div><div class="toprow"><span>Jour/nuit</span><span><?= $requester->getValue('daynight') == TRUE ? 'Jour' : 'Nuit' ?></span></div></div>
  <div><div class="toprow"><span>Météo</span><span><?= getWeather($requester) ?></span></div></div>
  <div><div class="toprow"><span>Uptime</span><span><?= date("H:i:s", floor($requester->getValue('uptime') / 1000)) ?></span></div></div>
  <div><div class="toprow"><span>TPS (overworld)</span><span><?= $requester->getValue('tps')['0']['tps'] ?>/20</span></div></div>
  <div><div class="toprow"><span>TPS (nether)</span><span><?= $requester->getValue('tps')['-1']['tps'] ?>/20</span></div></div>
  <div><div class="toprow"><span>TPS (end)</span><span><?= $requester->getValue('tps')['1']['tps'] ?>/20</span></div></div>
</div>

...

<?php
foreach ($players as $player=>$death)
{
  echo "<tr><td>" . $player . "</td>";
  echo "<td>" . $deaths['LEADERBOARD'][$player] ?? '0' . "</td>";
  echo "<td>" . $death . "</td></tr>";
}
?>

But since the problem seems to be server side, I don't think there could be any clue on the web side. I hope this will help you solving the issue. Btw, you did a great job, I was looking to add data like, last time online or latestDeath, then I found your mod, that was so helpful ! You really enhance the minecraft query which is really poor data serving ... :'(