Closed ccondrup closed 15 years ago
First of all you could always surround your specific code with a try catch
block to handle the exception. That's why I chose to throw an exception in the first place, because it's easier to handle for the user.
On the other hand I don't see, why one of your servers should return this error - especially when both are on the same machine. This error usually indicates that you're trying to query the wrong IP and/or port.
PS: Sorry for my response taking so long. :)
Sorry my question was not very specific. I am new to this kind of error/exception-handling, and was wondering if there are other fancy tricks one usually does in the catch-block. Currently I just have:
catch (Exception $e) {
echo "Could not connect to server.
Error message: " . $e->getMessage();
echo "
}
Oh, and you were absolutely right, I forgot we have taken one server down, so this box now runs GoldSrc on 27015 and 27016, and I tried to use getPlayers(rcon) on 27017 - I just thought that Condenser would detect and throw a more understandable error (Like "Could not connect to server, most likely wrong ip/port"). Or call it a "SocketReadException" or something more describing, so we can give a more helpful error message. I think that when the error is about sockets people will take that literally and look in the wrong places like I just did.
Feel free to go ahead and close this. I would appreciate some pointers on the first Q though. Thanks!
I admit the error handling may need some work, but it serves well in most of the cases.
Instead of just using the catch
block to print the exception you could also use this to implement your own logic for catching errors. This isn't very useful when you're querying the wrong IP/port, but it's quite helpful for handling timeouts etc.
Not an issue with the library, but rather the usage. This might be a FAQ as time goes by? Anyways, 2 of my 10 servers always give this error: Fatal error: Uncaught exception 'Exception' with message 'Could not read from socket.' in /lib/Socket.php:156
I am just wondering what this could be caused by, and how to fix this? I have one Linux server which runs 2x GoldSrc servers, port 27015 and 27016, so network/firewalls etc are identical for both. The first one works fine with Steam-condenser, but the second on port 27016 always gives the above error. The servers are very similar in setup+config as well. Where should I start to check for errors? How would we code a useful error-catcher for this so the script can continue? - I loop through the 10 servers to update info from all, but because of this error the script stops. Any help appreciated!