Giter VIP home page Giter VIP logo

Comments (3)

MineTheCube avatar MineTheCube commented on August 27, 2024

Hi,

First, what's the IP you're trying to ping?

Then try adding this on top of the script (right after <?php):

error_reporting(E_ALL);
ini_set('display_errors', true);

And re-run your script. If an error is shown, please give it me back.

If not, try this in another file:

<?php
echo 'They are both required to be true: ';
var_dump(function_exists('fsockopen'));
var_dump(is_resource(fsockopen("play.onecraft.fr", 25565, $errNo, $errStr, 3)));

And tell me what you got.

from mojangapi.

Zonigaru avatar Zonigaru commented on August 27, 2024

Hi,

I respond to the place of LEN-studios because I have the same problem.

error_reporting(E_ALL);
ini_set('display_errors', true);

It doesn't show anything special.

echo 'They are both required to be true: ';
var_dump(function_exists('fsockopen'));
var_dump(is_resource(fsockopen("play.onecraft.fr", 25565, $errNo, $errStr, 3)));

I receive : True, True.

In "query" function :

// Send handshake
   $data = self::queryWriteData($socket, 0x09);
   var_dump($data);

I receive : false, every time.

from mojangapi.

MineTheCube avatar MineTheCube commented on August 27, 2024

What is your PHP version?
Which server are you trying to query?
Where is your script hosted?

Try to change queryWriteData function:

    private static function queryWriteData($socket, $command, $append = '')
    {
        $command = pack('c*', 0xFE, 0xFD, $command, 0x01, 0x02, 0x03, 0x04) . $append;
        $length  = strlen($command);

        $writeLength = fwrite($socket, $command, $length);
        if ($length !== $writeLength) {
            var_dump('Wrong length, got:', $writeLength, ', expected:', $length);
            return false;
        }
        
        $data = fread($socket, 4096);
        if ($data === false or strlen($data) < 5 or $data[0] != $command[2]) {
            if ($data === false) {
                var_dump('Data was false');
            } else if (strlen($data) < 5) {
                var_dump('Unexpected data length: ', strlen($data));
            } else if ($data[0] != $command[2]) {
                var_dump('data[0] ≠ command[2], data was:', $data[0], ', command was:', $command[2]);
            }
            return false;
        }
        
        return substr($data, 5);
    }

It should print where it failed.

from mojangapi.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.