Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove throwing TransportException on readLine() #195

Conversation

Sebbo94BY
Copy link
Collaborator

@Sebbo94BY Sebbo94BY commented Mar 10, 2023

@ronindesign I am not sure, why we are throwing a TransportException here, if there is no data and line anymore.

I've developed a client, which stays connected and regulary executes ServerQuery commands like getting the current clientlist and in case of timeouts, it sends a keepalive 50 seconds before the timeout occurs.

However... This else code here always causes a connection lost within the first 5 seconds after connecting, when the second ServerQuery command gets executed:

www-data@4a53142831ba:~$ php artisan instance:start-teamspeak-bot
Starting TeamSpeak bot instance
Caching the current datetime in various formats...
Caching the current client list...
Caching the current servergroup list...

   PlanetTeamSpeak\TeamSpeak3Framework\Exception\TransportException 

  connection to server 'localhost:10022' lost

  at vendor/planetteamspeak/ts3-php-framework/src/Transport/TCP.php:162
    158▕             if ($data === false) {
    159▕                 if ($line->count()) {
    160▕                     $line->append($token);
    161▕                 } else {
  ➜ 162▕                     throw new TransportException("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
    163▕                 }
    164▕             } else {
    165▕                 $line->append($data);
    166▕             }

      +6 vendor frames 
  7   app/Http/Controllers/Helpers/BotController.php:94
      PlanetTeamSpeak\TeamSpeak3Framework\Node\Server::serverGroupClientList()

I've manually removed this else part in my local vendor/ directory and then everything is working as expected. I also didn't notice any bad side effects when removing this piece of code. Without this code, my client stays connected for multiple hours without any issues.

Could you please double-check this and decide, whether we can simply remove this code or if we need to fix something else?

@Sebbo94BY
Copy link
Collaborator Author

Did you had the chance to take a look at this topic, @ronindesign ?

This is currently a blocker for using this library for bot features on PHP 8.1/8.2.

@Sebbo94BY
Copy link
Collaborator Author

@ronindesign could you please take a look at this change?

@Sebbo94BY
Copy link
Collaborator Author

Any updates regarding this, @ronindesign ?

@MatthiasHeinz
Copy link

This would probably also resolve issue #204.

@ronindesign
Copy link
Collaborator

Thank you for the contribution and testing as well, really appreciate it!

@Sebbo94BY Sebbo94BY deleted the Remove-wrong-throwing-transport-exception branch August 3, 2023 19:58
@ronindesign ronindesign mentioned this pull request Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants