Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Minecraft Server Pinger

In this python script I wanted to try and Ping my Minecraft Java Server so it could always stay online. I’m not to familiar with servers, especially Minecraft Servers. Does anyone know how to do this, or how to fix my Script.

import requests
import time

#Minecraft Server Pinger

server_ip="Server.aternos.me"

port={"Server.aternos.me": 12345678910}
#      Server IP             Port

while True:
    time.sleep(280)
    server_ping=requests.post(server_ip, port)
    print(server_ping)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

There is a python package called mcstatus that does this easier if you don’t want figure out how the networking for pinging works.

Just run pip install mcstatus

And then your code is as simple as:

from mcstatus import MinecraftServer

server = MinecraftServer.lookup("example.org:1234")

latency = server.ping()
print(f"The server replied in {latency} ms")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading