koraktor / steam-condenser

A multi-language library for querying the Steam Community, Source, GoldSrc servers and Steam master servers
https://koraktor.de/steam-condenser
Other
359 stars 65 forks source link

TimeoutException when executing master.getServers() in Java #254

Closed shirgazee closed 10 years ago

shirgazee commented 10 years ago

I'm trying to query GoldSrc master server and get a list of game servers using Java. I used this code as in the example:

MasterServer master = new MasterServer("hl1master.steampowered.com:27011");  
Vector<InetSocketAddress> servers = master.getServers();

Looks like that SteamCondenser is waiting for more packets from master server and doesn't get them:

debug:
авг 28, 2014 11:54:48 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:49 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:49 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:49 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:49 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:50 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:50 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:50 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:50 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:50 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:50 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:50 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:50 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:51 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:51 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:51 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:51 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:51 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:51 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:51 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:51 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:52 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:52 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:52 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:52 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:52 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:52 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:52 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:52 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:53 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:53 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:53 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:53 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:53 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:53 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:53 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:53 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:54 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:54 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:54 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:54 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:54 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:54 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:55 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:55 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:55 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:55 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:55 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:55 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:55 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:55 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:56 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:56 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:56 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:56 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:56 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:56 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:56 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:56 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:57 AM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 11:54:57 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:58 AM com.github.koraktor.steamcondenser.steam.servers.MasterServer getServers
INFO: Request to master server hl1master.steampowered.com/208.64.200.117 timed out, retrying...
авг 28, 2014 11:54:58 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:54:59 AM com.github.koraktor.steamcondenser.steam.servers.MasterServer getServers
INFO: Request to master server hl1master.steampowered.com/208.64.200.117 timed out, retrying...
авг 28, 2014 11:54:59 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:55:00 AM com.github.koraktor.steamcondenser.steam.servers.MasterServer getServers
INFO: Request to master server failed, retrying hl1master.steampowered.com/208.64.200.118...
авг 28, 2014 11:55:00 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:55:01 AM com.github.koraktor.steamcondenser.steam.servers.MasterServer getServers
INFO: Request to master server hl1master.steampowered.com/208.64.200.118 timed out, retrying...
авг 28, 2014 11:55:01 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 11:55:02 AM com.github.koraktor.steamcondenser.steam.servers.MasterServer getServers
INFO: Request to master server hl1master.steampowered.com/208.64.200.118 timed out, retrying...
авг 28, 2014 11:55:02 AM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
Exception in thread "main" java.util.concurrent.TimeoutException
    at com.github.koraktor.steamcondenser.steam.sockets.SteamSocket.receivePacket(SteamSocket.java:112)
    at com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket.getReply(MasterServerSocket.java:49)
    at com.github.koraktor.steamcondenser.steam.servers.MasterServer.getServers(MasterServer.java:277)
    at com.github.koraktor.steamcondenser.steam.servers.MasterServer.getServers(MasterServer.java:197)
    at steamscanner.SteamScanner.main(SteamScanner.java:29)
Java Result: 1
BUILD SUCCESSFUL (total time: 20 seconds)

Am I doing something wrong or should I check my network preferences?

koraktor commented 10 years ago

You might try the following to force return of all servers that were retrieved before the timeout occured.

master.getServers(MasterServer.REGION_AL, "", true);

Fixing the timeout may be possible by raising the time limit:

SteamSocket.setTimeout(5000);
shirgazee commented 10 years ago

Thank you for the reply. I succeed in getting server list 2 times during this day. The most common error was still the TimeoutException, also I got "Permission denied" and many times my code just got stuck after sending data packet:

debug:
Exception in thread "main" com.github.koraktor.steamcondenser.exceptions.SteamCondenserException: Permission denied: connect
    at com.github.koraktor.steamcondenser.steam.sockets.QuerySocket.<init>(QuerySocket.java:44)
    at com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket.<init>(MasterServerSocket.java:35)
    at com.github.koraktor.steamcondenser.steam.servers.MasterServer.initSocket(MasterServer.java:318)
    at com.github.koraktor.steamcondenser.steam.servers.Server.<init>(Server.java:83)
    at com.github.koraktor.steamcondenser.steam.servers.MasterServer.<init>(MasterServer.java:118)
    at steamscanner.SteamScanner.main(SteamScanner.java:31)
Caused by: java.net.SocketException: Permission denied: connect
    at sun.nio.ch.Net.connect0(Native Method)
    at sun.nio.ch.Net.connect(Net.java:435)
    at sun.nio.ch.DatagramChannelImpl.connect(DatagramChannelImpl.java:738)
    at com.github.koraktor.steamcondenser.steam.sockets.QuerySocket.<init>(QuerySocket.java:42)
    ... 5 more
Java Result: 1

INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 7:19:33 PM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 7:19:33 PM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 7:19:33 PM com.github.koraktor.steamcondenser.steam.sockets.MasterServerSocket getReply
INFO: Received reply of type "M2A_SERVER_BATCH_Paket"
авг 28, 2014 7:19:33 PM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 7:19:38 PM com.github.koraktor.steamcondenser.steam.servers.MasterServer getServers
INFO: Request to master server hl1master.steampowered.com/208.64.200.117 timed out, retrying...
авг 28, 2014 7:19:38 PM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
авг 28, 2014 7:19:43 PM com.github.koraktor.steamcondenser.steam.servers.MasterServer getServers
INFO: Request to master server hl1master.steampowered.com/208.64.200.117 timed out, retrying...
авг 28, 2014 7:19:43 PM com.github.koraktor.steamcondenser.steam.sockets.QuerySocket send
INFO: Sending data packet of type "A2M_GET_SERVERS_BATCH2_Paket"
koraktor commented 10 years ago

"Permission denied" is a local client problem, probably caused by some operating system restrictions, but maybe also related to IPv6, VPN and other factors.

shirgazee commented 10 years ago

I don't know why but everything runs great on my other machine. Sorry and thanks for your help. Will you add support for new steamIDs that are used on servers like "U:1:12345" instead of "STEAM_0:0:12345"?

koraktor commented 10 years ago

Ok, great to hear it works for you now.

New Steam IDs are already supported in SteamId#convertSteamIdToCommunityId(). Are you missing something?

shirgazee commented 10 years ago

I thought it was something new in Steam and didn't find this in javadoc. Thanks for your help!