Comments (10)
By the way since 1.7 the regular server list ping (using the .status()
method) includes a limited list of players connected to the server. This should work on all servers without modifying servers.properties
to enable the Query proto.
from mcstatus.
Sure -- you may want to read the official python tutorial, however.
Run it like this:
$ python2 ping_example.py 54.69.165.139
A Minecraft Server (54.69.165.139) v1.8.3 210.007ms 2/20 dummy, blue_calx
#!/usr/bin/env python
from mcstatus.server import MinecraftServer
import sys
def print_status(address):
server = MinecraftServer(address)
status = server.status()
if status.players.sample:
players_string = ', '.join(p.name for p in status.players.sample)
else:
players_string = ''
print('{0} ({1}) v{2} {3}ms {4}/{5}{6}{7}'.format(
status.description,
address,
status.version.name,
status.latency,
status.players.online,
status.players.max,
bool(players_string)*' ', # Only include space if there is data.
players_string,
))
def main():
for arg in sys.argv[1:]:
print_status(arg)
if __name__ == '__main__':
main()
from mcstatus.
Can you paste your script here or on hastebin.com or something?
from mcstatus.
Right now i'm just trying to get the query feature to work so im using the code supplied on the main page of the repository.
the code i'm using is below and in its entirety (i removed the ip as i shouldn't be giving it out):
from mcstatus import MinecraftServer
If you know the host and port, you may skip this and use MinecraftServer("example.org", 1234)
server = MinecraftServer("i purposely removed the ip")
query = server.query()
print("The server has the following players online: {0}".format(", ".join(query.players.names)))
from mcstatus.
Try this server: 54.69.165.139 -- it has the query proto enabled and has a dummy client connected.
It works for me using Python 2.7.6 and mcstatus 2.1 on Windows 7.
from mcstatus.
Thanks, it would appear that I set something up wrong in the server properties as the ip winny supplied works great. Thank you all for the help
from mcstatus.
Sorry but i'm rather new to python and as a result i can't get the .status() method of receiving a limited list of names names to work. Would it be possible for someone to leave an example of how to use this method?
from mcstatus.
Really, bringing an old thread back to life by posting a useless comment?
from mcstatus.
I have the same problem using mcstatus 2.1 in a Django app. The problem also occurs when using mcstatus outside of the Django app. I also tested it with Python 2.7, on Windows, and Linux - no difference. It always just times out during the UDP handshake. Maybe related to #37? Any solution?
The minecraft server is version 1.8.8 and I can query it just fine via https://dinnerbone.com/minecraft/tools/status/. Assuming this uses the same code, I don't quite understand the problem.
When I disable my firewall instead of the timeout I receive the following error at the same location:
Exception Value: [WinError 10054] An existing connection was forcibly closed by the remote host
Django Version: 1.8.4
Python Version: 3.5.0
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mclobby')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Traceback:
File "C:\Users\Mathias\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\handlers\base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Mathias\PycharmProjects\mclobby\mclobby\views.py" in query
27. query = server.query()
File "C:\Users\Mathias\AppData\Local\Programs\Python\Python35-32\lib\site-packages\mcstatus\server.py" in query
82. raise exception
File "C:\Users\Mathias\AppData\Local\Programs\Python\Python35-32\lib\site-packages\mcstatus\server.py" in query
77. querier.handshake()
File "C:\Users\Mathias\AppData\Local\Programs\Python\Python35-32\lib\site-packages\mcstatus\querier.py" in handshake
32. packet = self._read_packet()
File "C:\Users\Mathias\AppData\Local\Programs\Python\Python35-32\lib\site-packages\mcstatus\querier.py" in _read_packet
25. packet.receive(self.connection.read(self.connection.remaining()))
File "C:\Users\Mathias\AppData\Local\Programs\Python\Python35-32\lib\site-packages\mcstatus\protocol\connection.py" in read
172. result.extend(self.socket.recvfrom(self.remaining())[0])
Exception Type: timeout at /query
Exception Value: timed out
from mcstatus.
@Bunkerbewohner Please create your own issue instead of piggybacking off of someone else's.
Locking this conversation.
from mcstatus.
Related Issues (20)
- MCSTATUS raw HOT 2
- Can't ping server on Termux HOT 5
- How do I run mcstatus? HOT 1
- status.version does not have a sensible string representation HOT 3
- Drop support for python 3.6
- Decode ISO 8859-1 into UTF-8
- minecrafBedrockServer failing to connect to a server HOT 5
- TypeError: an integer is required (got type NoneType) HOT 2
- Community Chat? HOT 2
- Key existence for COLOR_MAP is not being checked HOT 3
- Complex Description Styles are lacking test coverage HOT 3
- How to get server name / motd ?
- Update click to 8.0.0 HOT 2
- Raising errors on invalid ip requires rewrite of client logic HOT 15
- Support multiple types of formatting for MOTD
- Synchronous operations inside async functions HOT 1
- To replace sync 'dns.resolver.resolve' with `dns.asyncresolver` HOT 1
- UDPAsyncSocketConnection cannot write anything special itself HOT 3
- Unable to use module in a python script HOT 5
- Getting timeout for status.plays.online HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mcstatus.