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

Can't ping server on Termux #179

Closed PerchunPak closed 2 years ago

PerchunPak commented 2 years ago
~ $ pkg update
Checking availability of current mirror: ok
Hit:1 https://packages-cf.termux.org/apt/termux-main stable InRelease
Hit:2 https://packages.termux.org/apt/termux-games games InRelease
Hit:3 https://packages.termux.org/apt/termux-science science InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.                                               
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done                                                 
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
~ $ pip install -U mcstatus
Requirement already satisfied: mcstatus in /data/data/com.termux/files/usr/lib/python3.10/site-packages (6.5.0)
Requirement already satisfied: asyncio-dgram>=1.2.0 in /data/data/com.termux/files/usr/lib/python3.10/site-packages (from mcstatus) (2.1.1)             
Requirement already satisfied: click>=7.1.1 in /data/data/com.termux/files/usr/lib/python3.10/site-packages (from mcstatus) (8.0.3)
Requirement already satisfied: six>=1.14.0 in /data/data/com.termux/files/usr/lib/python3.10/site-packages (from mcstatus) (1.16.0)
Requirement already satisfied: dnspython>=2.1.0 in /data/data/com.termux/files/usr/lib/python3.10/site-packages (from mcstatus) (2.1.0)                 
~ $ ping -c 5 hypixel.net
PING hypixel.net (104.17.71.15) 56(84) bytes of data.
64 bytes from 104.17.71.15: icmp_seq=1 ttl=61 time=9.01 ms                  
64 bytes from 104.17.71.15: icmp_seq=2 ttl=61 time=25.1 ms
64 bytes from 104.17.71.15: icmp_seq=3 ttl=61 time=24.5 ms
64 bytes from 104.17.71.15: icmp_seq=4 ttl=61 time=27.3 ms                  
64 bytes from 104.17.71.15: icmp_seq=5 ttl=61 time=43.7 ms

--- hypixel.net ping statistics ---                                         
5 packets transmitted, 5 received, 0% packet loss, time 4011ms
rtt min/avg/max/mdev = 9.013/25.971/43.795/11.044 ms
~ $ mcstatus hypixel.net status                                             
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/mcstatus", line 8, in <module>
    sys.exit(cli())                                                           
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)                                         
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/mcstatus/scripts/mcstatus.py", line 61, in status
    response = server.status()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/mcstatus/server.py", line 106, in status
    connection = TCPSocketConnection((self.host, self.port))
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/mcstatus/protocol/connection.py", line 187, in __init__
    self.socket = socket.create_connection(addr, timeout=timeout)
  File "/data/data/com.termux/files/usr/lib/python3.10/socket.py", line 845, in create_connection
    raise err
  File "/data/data/com.termux/files/usr/lib/python3.10/socket.py", line 833, in create_connection
    sock.connect(sa)
OSError: [Errno 101] Network is unreachable
~ $
kevinkjt2000 commented 2 years ago

This is your own network error. Check the firewalls for the UDP ping port which defaults to 25565 for Minecraft. ICMP pings are an entirely different protocol.

PerchunPak commented 2 years ago

Same command on my windows computer image

kevinkjt2000 commented 2 years ago

Again check your firewalls. Clearly mcstatus is working but is being blocked on TCP/UDP from the Linux machine you were using. I’m quite certain that termux makes no difference. (Unless there’s an additional firewall that only applies in termux)

PerchunPak commented 2 years ago

Yep, you right.

~ $ nc -z -v hypixel.net 25565
nc: connect to hypixel.net (104.16.78.21) port 25565 (tcp) failed: Connection timed out
nc: connect to hypixel.net (104.17.71.15) port 25565 (tcp) failed: Connection timed out
nc: connect to hypixel.net (2606:4700::6810:4e15) port 25565 (tcp) failed: Network is unreachable
nc: connect to hypixel.net (2606:4700::6811:470f) port 25565 (tcp) failed: Network is unreachable

One question is left, how disable firewall in my MIUI? Seems like this question will left without answer.

kevinkjt2000 commented 2 years ago

Yes that question is beyond this issue tracker. The best we can do is point out that the network port is being blocked.