Dinnerbone / mcstatus

A Python class for checking the status of an enabled Minecraft server
http://dinnerbone.com/minecraft/tools/status/
1.11k stars 146 forks source link

query() not working #55

Closed EnderInvader closed 5 years ago

EnderInvader commented 7 years ago

I can't get the query() to work. I have enable-query set to true. I am just running the example code on the front page.

Traceback (most recent call last): File "C:/Users/User/Desktop/server_status.py", line 17, in <module> query = server.query() File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\mcstatus\server.py", line 82, in query raise exception File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\mcstatus\server.py", line 77, in query querier.handshake() File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\mcstatus\querier.py", line 32, in handshake packet = self._read_packet() File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\mcstatus\querier.py", line 25, in _read_packet packet.receive(self.connection.read(self.connection.remaining())) File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\mcstatus\protocol\connection.py", line 175, in read result.extend(self.socket.recvfrom(self.remaining())[0]) socket.timeout: timed out

EnderInvader commented 7 years ago

The server says Query running on 0.0.0.0:25565

MarkL4YG commented 7 years ago

If the server runs on 0.0.0.0:25565 that only means the server will respond on all network addresses the machine he's running on has assigned to itself. If you entered that as server address you need to change that to a real network address pointing to that server. 127.0.0.1 ( localhost) e.g. if it's on the same machine.

EnderInvader commented 7 years ago

The server address is set to my public ip, but the query is set to 0.0.0.0 and I don't know why. I think that is why query() isn't working.

EnderInvader commented 7 years ago

Do I need the change the server-ip= in the server.properties file?

MarkL4YG commented 7 years ago

I guess you're not setting your mcstatus up correctly.
Take a look at this (from the readMe):

# If you know the host and port, you may skip this and use MinecraftServer("example.org", 1234)
server = MinecraftServer.lookup("example.org:1234")

example.org needs to be your domain/address in your case.

Whatever you edit in the server.properties does only change to what address the MC server answers to not that you don't provide the correct address to mcstatus.

EnderInvader commented 7 years ago

I have my address correctly in place the status() and ping() work just fine, the query() is the only one that doesn't work.

MarkL4YG commented 7 years ago

Did you also make sure that server querying is enabled in your server.properties? You should search for enable-query=

turtle2472 commented 7 years ago

My server is also no longer responding to query. Ping and status work as expected, query does not though.

minecraft@anmc7 [~]# mcstatus localhost ping
1.167ms
minecraft@anmc7 [~]# mcstatus localhost status
version: v1.12.1 (protocol 338)
description: "{u'text': u'1.12 Polly want a block? SQUAWK'}"
players: 1/20 ['me (e9xxxxd6-xxxx-xxxx-xxxx-f7dcxxxxea7b)']
minecraft@anmc7 [~]# mcstatus localhost query
Traceback (most recent call last):
  File "/bin/mcstatus", line 9, in 
    load_entry_point('mcstatus==2.2', 'console_scripts', 'mcstatus')()
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/mcstatus/scripts/mcstatus.py", line 79, in query
    response = server.query()
  File "/usr/lib/python2.7/site-packages/mcstatus/server.py", line 82, in query
    raise exception
socket.timeout: timed out

I say no longer because something changed and I haven't narrowed it down yet. I was good until 9:50pm tonight. I use zabbix to graph and log the data. https://www.dropbox.com/s/4y3hkxd3k3xzxy3/Screenshot%202017-08-26%2022.59.07.png?raw=1

CentOS7, enable-query=true, query.port=25565

turtle2472 commented 7 years ago

Mine is resolved now. In my case "localhost" quit working. I was able to set it to my actual external hostname and now it resolves fine. Not sure why localhost quit working for query only though.

MarkL4YG commented 7 years ago

Did you set a bind address in the server.properties?

turtle2472 commented 7 years ago

server-ip is blank. I'm behind a firewall with port forwarding.

MarkL4YG commented 7 years ago

Hmm... that's weird but if using the fully qualified domain resolves that I guess it's not that big of a deal.

turtle2472 commented 7 years ago

Right. I'm really frustrated that I didn't notice it until after I had done a number of updates and changes on the MC server so I have no way to pinpoint the change made that caused it to no longer work with just "localhost".

turtle2472 commented 7 years ago

For the record I'll add that it now works with localhost again. I have no idea what changed or why it now works with localhost again.

# mcstatus localhost query
host: 192.168.x.x:25565
software: v1.12.1 vanilla
plugins: []
motd: "witty motd"
players: 0/20 []
kevinkjt2000 commented 5 years ago

If I'm reading this correctly, the issue appears resolved.