Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

[solved] Socket closed #3

Closed
punkeel opened this issue Aug 15, 2016 · 10 comments
Closed

[solved] Socket closed #3

punkeel opened this issue Aug 15, 2016 · 10 comments

Comments

@punkeel
Copy link

punkeel commented Aug 15, 2016

Hello,

There is no support if the socket is closed: the while loops becomes an infinite loop here: https://github.com/par0noid/ts3admin.class/blob/master/lib/ts3admin.class.php#L4211

What about adding basic support for detecting dead sockets?

Thx! :)

@Speckmops
Copy link
Owner

Hey PunKeel,

thanks for your message.

I'll take a look at this the next days :) code suggestions welcome

Best regards
Stefan

@Speckmops Speckmops added the bug label Aug 15, 2016
@Speckmops Speckmops self-assigned this Aug 15, 2016
@Speckmops
Copy link
Owner

I'm still trying to find a solution for detecting death connections. Mabye @Viper61 could help? 😆

@Speckmops
Copy link
Owner

Speckmops commented Oct 19, 2016

Currently I have no idea how to solve this :-(

@Nik99
Copy link
Contributor

Nik99 commented Oct 19, 2016

I found this function here, i dont know if it can help you @par0noid
http://php.net/manual/en/function.socket-get-status.php

@toxiicdev
Copy link
Contributor

@par0noid Just try to send a packet to check if socket is alive 👍

@TheVaan
Copy link

TheVaan commented Oct 19, 2016

I think @toxiicdev s idea is a good way. Or you can do a socket_get_status() and check if the socket is open/connected.
The link above dosn't show to the correct line anymore... which is the correct line now?

@toxiicdev
Copy link
Contributor

@TheVaan Yea I think that socket_get_status() would be a better solution, but we should be sure that it works properly.

@toxiicdev
Copy link
Contributor

@everyone Take a look here: #8

@Speckmops
Copy link
Owner

Thank you guys, especially @toxiicdev for your help! Version 1.0.1.3 is out now with your bugfix. Together we can achieve anything! ♥

@Speckmops Speckmops changed the title Socket closed [solved] Socket closed Oct 20, 2016
@MINORITYmaN
Copy link

MINORITYmaN commented Nov 15, 2016

hi there,
if a deamon is connected to the socket and the server shuts down, cpu jumps to 100%.
this happens if a command is issued or if the destructor is called which calls logout.
imho this should have a detection too.

i made a imho ugly workaround, have 2 different ways for it:

  1. using a custom function including Closure::bind
  2. using ReflectionClass including ReflectionProperty::getValue and setAccessible

both do the same, they give me the chance to access the runtime property to reach the socket.

  • during main loop of the deamon before the commands i have to make a new socket connection to check if the query port is listening, if negative then i access the private runtime socket and close it.
  • after that i set the ts3admin class to NULL, and loop until the port gets open again to let the deamon log in to do his job.

this operation is necessary cuz the socket session will be invalid if the server comes up again.

imho, the class could have a property/var which switches when the socket state changes from online to offline without having to build workarounds like the 2 i wrote before.

a deamon could just access this property to know if its allowed to run commands or do other operations (for example try to reconnect, sent to a website/db a info that the server went offline).

perhaps some of you have a better way to get it done without manipulating the main class.

let me know what you think about.
kind regards, stefano

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants