Closed Javierko closed 5 years ago
Hmm, it seems like the connection timed out, maybe while trying to read, or waiting to read, from the server...
Here is my ufw status: https://hastebin.com/inazopimol.makefile
Firewall shouldn't matter, unless your bot can't connect in the first place?
We need more information. Details about your situation, code, what's working, what isn't, etc.
Here is my code for using TS3 framework: https://hastebin.com/ubotaqemup.php Error that I uploaded up i got using: catch (Exception $e) { echo $e; }
I dont understand what you mean:
your bot can't connect in the first place?
Btw I have installed package "fail2ban", do you think that can cause some problems?
I'm able to connect to 185.91.116.243:10011
without issue, so it's not an issue of firewall or fail2ban.
Does the exception happen immediately or does it take time to hang and then has error?
Also, you might try connecting without server_port=9987
and then selecting the virtual server manually with $ts3->serverGetById()
to see if you're getting any errors.
Also, maybe just try to echo $ts3->getProperty("virtualserver_status");
and see if you're even getting that far?
One thing I noticed, you have:
$now_ts3 = $ts3->getProperty("virtualserver_clientsonline") - $ts3->getProperty("virtualserver_queryclientsonline");
But you included no_query_clients=1
in your ::factory()
, so $ts3->getProperty("virtualserver_queryclientsonline")
should always be 0, and maybe this is causing an issue?
Otherwise, I would just recommend troubleshooting by removing some of your code until it starts working, then you'll know what part of your code is giving you trouble.
After using echo $ts3->getProperty("virtualserver_status");
i got nothing, any output.
Also when I am using only this, i still got output "offline": https://hastebin.com/pedatokata.php
I tried error ouput with echo "Error " . $e->getCode() . ": " . $e->getMessage();
got: Error 0: connection to server '185.91.116.243:10011' lost
Maybe try something like this:
Still getting same error:
Error 0: connection to server '185.91.116.243:10011' lost
I just tested this code and it worked fine for me:
<?php
require_once '~/ts3phpframework-release/libraries/TeamSpeak3/TeamSpeak3.php';
try
{
$ts3 = TeamSpeak3::factory("serverquery://LOGIN@185.91.116.243:10011?use_offline_as_virtual=1");
$ts3->serverGetByPort(9987);
echo "online";
}
catch(Exception $e)
{
echo "offline";
}
Is your PHP code running on the same server (or network) as TeamSpeak Server? If so, you'll need to use local IP, such as:
$ts3 = TeamSpeak3::factory("serverquery://LOGIN@127.0.0.1:10011?use_offline_as_virtual=1");
Your original code works just fine as well:
require_once '~/ts3phpframework-release/libraries/TeamSpeak3/TeamSpeak3.php';
TeamSpeak3::init();
$status_ts3 = '<span class="badge label-success" style="border-width: 1px; border-style: solid; background-color: transparent; border-color: #ef1c1c; color: #ef1c1c; border-radius: 0px; font-size: 12px;">OFFLINE</span>';
$now_ts3 = 0;
$max_ts3 = 0;
try
{
$ts3 = TeamSpeak3::factory("serverquery://LOGIN@185.91.116.243:10011/?server_port=9987&use_offline_as_virtual=1&no_query_clients=1");
$status_ts3 = $ts3->getProperty("virtualserver_status");
if ($status_ts3 == "online")
{
$status_ts3 = '<span class="badge label-primary" style="border-width: 1px; border-style: solid; background-color: transparent; border-color: #63bf29; color: #63bf29; border-radius: 0px; font-size: 12px;">ONLINE</span>';
}
$now_ts3 = $ts3->getProperty("virtualserver_clientsonline") - $ts3->getProperty("virtualserver_queryclientsonline");
$max_ts3 = $ts3->getProperty("virtualserver_maxclients");
echo "Now: $now_ts3 | Max: $max_ts3";
} catch (Exception $e) { }
Running this, I get:
$ php test.php
Now: 37 | Max: 100
No, I dont run code on same server as TS3. But also I am still getting output offline.
I think, there must be some problem on my server.
I agree, it seems network related.
It's possible sometimes the server where code is running, can have firewall or internet access that blocks outbound traffic on other ports (such as 10011
). I would recommend trying to:
telnet 185.91.116.243 10011
from the server where your code is running.
If you get no connection, then you know something is wrong for sure with the network.
Ouput after using telnet 185.91.116.243 10011
Trying 185.91.116.243... Connected to 185.91.116.243. Escape character is '^]'. Connection closed by foreign host.
Ouput for netstat -tlpn
tcp 0 0 127.0.0.1:3306 0.0.0.0: LISTEN 637/mysqld tcp 0 0 0.0.0.0:21 0.0.0.0: LISTEN 2611/vsftpd tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 525/sshd tcp6 0 0 :::80 ::: LISTEN 27818/apache2 tcp6 0 0 :::22 ::: LISTEN 525/sshd tcp6 0 0 :::443 ::: LISTEN 27818/apache2
Yeah, so your network has a problem. You should be getting this:
$ telnet 185.91.116.243 10011
Trying 185.91.116.243...
Connected to 185.91.116.243.
Escape character is '^]'.
TS3
Welcome to the TeamSpeak 3 ServerQuery interface, type "help" for a list of commands and "help <command>" for information on a specific command.
I suppose it's possible Fail2Ban may have banned your IP? But I would have thought the connection would fail differently. Try shutting down Fail2Ban and see if you can telnet then. It's definitely not ufw, as I'm able to connect through your firewall without issue.
I didnt find 185.91.116.243 in banned IPs. I removed Fail2Ban, but I am still getting server offline.
Ouput for netstat -tlpn
tcp 0 0 127.0.0.1:3306 0.0.0.0: LISTEN 637/mysqld tcp 0 0 0.0.0.0:21 0.0.0.0: LISTEN 2611/vsftpd tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 525/sshd tcp6 0 0 :::80 ::: LISTEN 27818/apache2 tcp6 0 0 :::22 ::: LISTEN 525/sshd tcp6 0 0 :::443 ::: LISTEN 27818/apache2
Also here is my packages list by apt list --installed
https://hastebin.com/qudedunemo.apache
If you don't get the "TS3... Welcome..." message when you telnet 185.91.116.243 10011
, then this is a network problem.
It will be either on the server where you're running the code or on the server that is running TeamSpeak 3 server.
You might also check if you can ping
/ traceroute
to 185.91.116.243
, this might show other possible network issues along the path.
That's weird... No I dont get this "TS3 ... wecolme" message.
Ping and traceroute works:
traceroute to 185.91.116.243 (185.91.116.243), 30 hops max, 60 byte packets 1 digitando-243-116-91-185.digitandoprazer.com.br (185.91.116.243) 1.078 ms 1.012 ms 0.957 ms
Why is your traceroute a single hop? You said the code and TeamSpeak 3 server are running on different servers?
Maybe you can post ifconfig
from both servers...
Yes, code and ts server are running on different server, but its single line that i got on php code server.
ifconfig from PHP code server (Debian 9): https://hastebin.com/uvohurixop.xml ifconfig from TS3 server (btw there is running Debian 8): https://hastebin.com/ojofeyeyos.nginx
Hmm, I do notice now in your comment above that when you telnet you do get Connected to 185.91.116.243.
, so this would suggest the network is actually fine.
The only other thing I can suspect is maybe the TeamSpeak 3 server banned your code server's IP for some reason?
I would recommend adjusting TS3 server's Anti-Flood settings, also whitelisting code server's IP in your query_ip_whitelist.txt
file (don't forget to restart server).
Also, check your TS3 server log file, looks something like logs/ts3server_2019-02-16__18_54_47.905429_1.log
and logs/ts3server_2019-02-16__18_54_47.905429_0.log
You should see log entry for whitelist, for example:
2019-00-00 07:58:46.934756|INFO |CIDRManager | | updated query_ip_whitelist ips: 127.0.0.1, 94.231.83.144, 94.231.83.146, 94.231.83.153, 94.231.83.148,
And also check log for other errors such as:
2019-00-00 09:46:12.996334|INFO |Query | | query from 3674 94.231.83.148:43572 attempted to login with account "XXX" and failed!
After adding my PHP code server IP into whitelist it works fine.
Thanks for help ^^
Hi, have someone idea how to fix this TCP error?
PHP ver: 7.0.33-0+deb9u3 OS: Debian 9