planetteamspeak / ts3phpframework

Modern use-at-will framework that provides individual components to manage TeamSpeak 3 Server instances
https://www.planetteamspeak.com
GNU General Public License v3.0
212 stars 59 forks source link

Error on TCP.php #146

Closed ArturVidal closed 4 years ago

ArturVidal commented 4 years ago

I have a error on file TCP.php Screenshot_2

Sebbo94BY commented 4 years ago

And which error @ArturVidal ? There is usually an error message above the stack trace. Without this, nobody can help you.

ArturVidal commented 4 years ago

[18-May-2020 22:24:28 Europe/Lisbon] PHP Fatal error: Uncaught TeamSpeak3_Transport_Exception: Connection timed out in /home/arturvid/public_html/scripts/banner/libraries/TeamSpeak3/Transport/TCP.php:55 Stack trace:

0 /home/arturvid/public_html/scripts/banner/libraries/TeamSpeak3/Transport/TCP.php(141): TeamSpeak3_Transport_TCP->connect()

1 /home/arturvid/public_html/scripts/banner/libraries/TeamSpeak3/Adapter/ServerQuery.php(73): TeamSpeak3_Transport_TCP->readLine()

2 /home/arturvid/public_html/scripts/banner/libraries/TeamSpeak3/Adapter/Abstract.php(57): TeamSpeak3_Adapter_ServerQuery->syn()

3 /home/arturvid/public_html/scripts/banner/libraries/TeamSpeak3/TeamSpeak3.php(338): TeamSpeak3_Adapter_Abstract->__construct(Array)

4 /home/arturvid/public_html/scripts/banner/banner.php(32): TeamSpeak3::factory(Object(TeamSpeak3_Helper_Uri))

5 {main}

thrown in /home/arturvid/public_html/scripts/banner/libraries/TeamSpeak3/Transport/TCP.php on line 55

Sebbo94BY commented 4 years ago

Looks like as you're trying to connect to an URI, which is not reachable. Please double-check your URI: Host, Port, Protocol

It's always recommend to use try-catch to avoid such errors:

<?php
// load framework files
require_once("libraries/TeamSpeak3/TeamSpeak3.php");

// register custom error message (supported placeholders are: %file, %line, %code and %mesg)
TeamSpeak3_Exception::registerCustomMessage(0x300, "The specified channel does not exist; server said: %mesg");

try
{
 // connect to local server, authenticate and spawn an object for the virtual server on port 9987
 $ts3_VirtualServer = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/?server_port=9987");
 // spawn an object for the channel using a specified name
 $ts3_Channel = $ts3_VirtualServer->channelGetByName("I do not exist");
}
catch(TeamSpeak3_Exception $e)
{
 // print the error message returned by the server
 echo "Error " . $e->getCode() . ": " . $e->getMessage();
}