fkubis / teamspeak-php-framework

GNU General Public License v3.0
18 stars 5 forks source link

event serverqueryWaitTimeout not triggering #8

Closed JABirchall closed 7 years ago

JABirchall commented 8 years ago

I am 99% sure that this isn't my code issue. But on my new bot project serverqueryWaitTimeout is not firing.

Subscription: https://github.com/JABirchall/NimdaTS3/blob/master/app/TeamSpeak3Bot.php#L150-L158

Event: https://github.com/JABirchall/NimdaTS3/blob/master/app/TeamSpeak3Bot.php#L460-L470

Update: 100% sure, Added tests in below comment!

JABirchall commented 8 years ago

Test cases: https://github.com/JABirchall/TeamspeakFrameworkTests/

While PlanetTeamspeaks framework fires after about 10 seconds. fkubis does not at all, and will not all the way to lose connection.

Edit test.php with your TeamSpeak settings in both folders and test for your self.

This bug needs to be fixed for any sort of bot implementation to work.

JABirchall commented 8 years ago

Here is the final frame before the exeption is thrown that the connection timed out in AbstractAdapter@waitForReadyRead

$null = null
$read = {array} [1]
 0 = {resource} resource id='26' type='stream'
$time = 0
$this = {TeamSpeak3\Transport\TCP} [3]
 config = {array} [4]
  host = {TeamSpeak3\Helper\StringHelper} [2]
   string = "127.0.0.1"
   position = 0
  port = 10011
  timeout = 1
  blocking = 0
 stream = {resource} resource id='26' type='stream'
 adapter = {TeamSpeak3\Adapter\ServerQuery} [6]
  host = {TeamSpeak3\Node\Host} [16]
   whoami = {array} [11]
   version = null
   serverList = null
   permissionEnds = null
   permissionList = null
   permissionCats = null
   predefined_query_name = {TeamSpeak3\Helper\StringHelper} [2]
   exclude_query_clients = false
   start_offline_virtual = false
   sort_clients_channels = false
   parent = {TeamSpeak3\Adapter\ServerQuery} [6]
   server = null
   nodeId = 0
   nodeList = null
   nodeInfo = {array} [0]
   storage = {array} [4]
  timer = 1471347169
  count = 9
  block = {array} [1]
   0 = "help"
  options = {array} [4]
   host = {TeamSpeak3\Helper\StringHelper} [2]
   port = 10011
   timeout = 1
   blocking = 0
  transport = {TeamSpeak3\Transport\TCP} [3]
   config = {array} [4]
   stream = {resource} resource id='26' type='stream'
   adapter = {TeamSpeak3\Adapter\ServerQuery} [6]
    host = {TeamSpeak3\Node\Host} [16]
    timer = 1471347169
    count = 9
    block = {array} [1]
    options = {array} [4]
    transport = {TeamSpeak3\Transport\TCP} [3]     

for some reason, time is 0 and so the timeout event does not fire.

JABirchall commented 8 years ago

@fkubis is not available?

fkubis commented 8 years ago

Sorry, Github did not notifiy my, dondt know why :(. Kam not shure why this happns, will take a deeper look later this week.

JABirchall commented 8 years ago

Yeah I tried to figure out why it wasn't working, edited the adapter classes still couldn't get it to stop timing out.

Too hard for me.

JABirchall commented 8 years ago

@fkubis I don't mean to rush you or be rude but my bot is nearing full release and the only thing really hold back progress is this bug. I'd like to add timers to the bot for scheduled tasks etc, But it would require the timeout event to fire.

Najsr commented 7 years ago

Hello, any progress made to fix the error?

JABirchall commented 7 years ago

Don't know if its related but this issue was raised on the original framework. https://github.com/planetteamspeak/ts3phpframework/commit/33616381cd8f5b8442b8c7988ec9e88dca9dae19

fkubis commented 7 years ago

Thats maybe helps. FYI iam working right now at this issue try to figure out whats exactly going on. But currently fighting with xdebug....

fkubis commented 7 years ago

@JABirchall I could not really reproduce this bug. Maybe the changes you related fixed this. Could you please give a try?

JABirchall commented 7 years ago

I will test now.

JABirchall commented 7 years ago

Ya still doesn't fire. http://i.imgur.com/1Hxa5V4.png

I will try do a stand alone test

Ya test fails too http://i.imgur.com/GQjBfso.png http://i.imgur.com/4k6jSv7.png

testcode

use TeamSpeak3\TeamSpeak3;
use TeamSpeak3\Helper\Signal;
include_once(__DIR__ . "/vendor/autoload.php");
$server = TeamSpeak3::factory("serverquery://serveradmin:password@127.0.0.1:10011/?server_port=9987&blocking=0");
Signal::getInstance()->subscribe("serverqueryWaitTimeout", "onWaitTimeout");
$server->getAdapter()->wait();
function onWaitTimeout($time, AbstractAdapter $adapter)
{
    echo "Timeout fired!";
    var_dump($time, $adapter);
}
JABirchall commented 7 years ago

@fkubis Your saviour has arrived, your not going to believe this O_O

the problem

it's trying to call unknownWaitTimeout

Successful Fire

And the source reason for it, in TeamSpeak3\Transport\AbstractTransport@getAdapterType returns TeamSpeak3\Adapter\ServerQuery Is not an instance of AbstractAdapter.

Now that i found the source i reverted to the old version and found that the event was fired to $signal = "teamspeak3\adapter\serverqueryWaitTimeout"

So infact it was never broken but just emiting under the full namespace so this code works fine

use TeamSpeak3\TeamSpeak3;
use TeamSpeak3\Helper\Signal;
include_once(__DIR__ . "/vendor/autoload.php");
$server = TeamSpeak3::factory("serverquery://serveradmin:password@127.0.0.1:10011/?server_port=9987&blocking=0");
Signal::getInstance()->subscribe(strtolower(\TeamSpeak3\Adapter\ServerQuery::class).'WaitTimeout', "onWaitTimeout");
$server->getAdapter()->wait();
echo "Test breakpoint not hit";
function onWaitTimeout($time, \TeamSpeak3\Adapter\AbstractAdapter $adapter)
{
    echo "Timeout fired!\n";
    var_dump($time, $adapter);
}

After such changes got the bot to work http://i.imgur.com/xxmMZ8c.png with

JABirchall commented 7 years ago

Created a pull request with the fix (that i found to work)

15

fkubis commented 7 years ago

Final you found it, thanks 👍