IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Erreur RCon 111


Sujet :

Langage PHP

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 30
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2014
    Messages : 7
    Points : 5
    Points
    5
    Par défaut Erreur RCon 111
    Salut,

    J'essaye d'envoyer des commandes à mon serveur Minecraft via mon site.
    Le serveur web et le serveur Minecraft sont hébergés sur la même machine et c'est un serveur dédié donc full accès.
    Le port RCon est 25566 et j'ai définis un mot de passe que je définirai par "mdp" ici.
    J'ai donc trouvé deux fichiers en fouillant sur le net mais j'ai une erreur : Unable to open socket: Connection refused (111)
    Voici le contenu des deux fichiers :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    <?php
    	include_once("rcon.php");
     
    	// Extend the rcon class to tweak it for minecraft.
    	class minecraftRcon extends rcon{
    		function mcSendCommand($Command){
    			$this->_Write(SERVERDATA_EXECCOMMAND,$Command,'');
    		}
    		function mcRconCommand($Command){
    			$this->mcSendcommand($Command);
    			$ret = $this->Read();
    			return $ret[$this->_Id]['S1'];
    		}
    	}
     
    	// Server connection varialbes
    	$server = "localhost";
    	$rconPort = 25566;
    	$rconPass = "mdp";
     
    	// Connect to the server
    	$r = new minecraftRcon($server, $rconPort, $rconPass);
     
    	// Authenticate, and if so, execute command(s)
    	if ( $r->Auth() ) {
    		echo "Authenticated !<br>";
     
    		// Send a command
    		var_dump($r->mcRconCommand('say Ca marche !'));
    	}else{
    		echo "Authentification failed !<br>";
    	}
    ?>
    Contenu de rcon.php
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    <?php
    /*
        Basic CS:S Rcon class by Freman.  (V1.00)
        ----------------------------------------------
        Ok, it's a completely working class now with with multi-packet responses
     
        Contact: printf("%s%s%s%s%s%s%s%s%s%d%s%s%s","rc","on",chr(46),"cl","ass",chr(64),"pri","ya",chr(46),2,"y",chr(46),"net")
     
        Behaviour I've noticed:
            rcon is not returning the packet id.
    */
     
    define("SERVERDATA_EXECCOMMAND",3);
    define("SERVERDATA_AUTH",0);
     
    class RCon {
        var $Password = "mdp";
        var $Host = "127.0.0.1";
        var $Port = 25566;
        var $_Sock = null;
        var $_Id = 0;
     
        function RCon ($Host,$port,$Password) {
            $this->Password = $Password;
            $this->Host = $Host;
            $this->Port = $Port;
            $this->_Sock = @fsockopen($this->Host,$this[4]->Port, $errno, $errstr, 30) or
                    die("Unable to open socket: $errstr ($errno)\n");
            $this->_Set_Timeout($this->_Sock,$Port,1);
            }
     
        function Auth () {
            $PackID = $this->_Write(SERVERDATA_AUTH,$this->Password);
     
            // Real response (id: -1 = failure)
            $ret = $this->_PacketRead();
            if ($ret[1]['id']) {
                die("Authentication Failure\n");
            }
        }
     
        function _Set_Timeout(&$res,$s,$m=0) {
            if (version_compare(phpversion(),'4.3.0','<')) {
                return socket_set_timeout($res,$s,$m);
            }
            return stream_set_timeout($res,$s,$m);
        }
     
        function _Write($cmd, $s1='', $s2='') {
            // Get and increment the packet id
            $id = $this->_Id;
     
            // Put our packet together
            $data = pack("VV",$id,$cmd).$s1.chr(0).$s2.chr(0);
     
            // Prefix the packet size
            $data = pack("S",strlen($data)).$data;
     
            // Send packet
            fwrite($this->_Sock,$data,strlen($data));
     
            // In case we want it later we'll return the packet id
            return $id;
        }
     
        function _PacketRead() {
            //Declare the return array
            $retarray = array();
            //Fetch the packet size
            while ($size = @fread($this->_Sock,4)) {
                $size = unpack('V1Size',$size);
                //Work around valve breaking the protocol
                if ($size["Size"] == 1024) {
                    //pad with 8 nulls
                    $packet = "\x00\x00\x00\x00\x00\x00\x00\x00".fread($this->_Sock,4086);
                } else {
                    //Read the packet back
                    $packet = fread($this->_Sock,$size["Size"]);
                }
                array_push($retarray,unpack("V1ID/V1Response/a*S1/a*S2",$packet));
            }
            return $retarray;
        }
     
        function Read() {
            $Packets = $this->_PacketRead();
     
            foreach($Packets as $pack) {
                if (isset($ret[$pack['ID']])) {
                    $ret[$pack['ID']]['S1'] .= $pack['S1'];
                    $ret[$pack['ID']]['S2'] .= $pack['S1'];
                } else {
                    $ret[$pack['ID']] = array(
                        'Response' => $pack['Response'],
                        'S1' => $pack['S1'],
                        'S2' =>    $pack['S2'],
                    );
                }
            }
            return $ret++;
        }
     
        function sendCommand($Command) {
            $Command = '"'.trim(str_replace(' ','" "', $Command)).'"';
            $this->_Write(SERVERDATA_EXECCOMMAND,$Command,'');
        }
     
        function rconCommand($Command) {
            $this->sendcommand($Command);
     
            $ret = $this->Read();
     
            //ATM: Source servers don't return the request id, but if they fix this the code below should read as
            // return $ret[$this->_Id]['S1'];
            return $ret[0]['S1'];
        }
    }
    ?>
    Voilà, si vous avez besoin de plus d'info n'hésitez pas à demander
    Et merci déjà à ceux qui prendront la peine de se pencher sur mon problème

  2. #2
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 30
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2014
    Messages : 7
    Points : 5
    Points
    5
    Par défaut
    Dans server.properties j'ai :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    enable-rcon=true
    rcon.port=25566
    rcon.password=mdp
    Et j'ai ouverts les ports :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    iptables -A INPUT -v -p TCP --dport 25566 -j ACCEPT
    iptables -A INPUT -v -p UDP --dport 25566 -j ACCEPT
    iptables -A OUTPUT -v -p TCP --dport 25566 -j ACCEPT
    iptables -A OUTPUT -v -p UDP --dport 25566 -j ACCEPT

  3. #3
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 30
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2014
    Messages : 7
    Points : 5
    Points
    5
    Par défaut
    Je précise qu'il n'est pas nécessaire d'utiliser ces scripts, si vous en trouvez d'autres, c'est bien aussi

  4. #4
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 30
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2014
    Messages : 7
    Points : 5
    Points
    5
    Par défaut
    Problème résolu. Mais sur un autre forum, avec le même titre et le même pseudo

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. erreur system error: 111
    Par nicolasSENAME dans le forum MySQL
    Réponses: 2
    Dernier message: 21/12/2009, 08h58
  2. [MySQL] erreur requete system error: 111
    Par nicolasSENAME dans le forum PHP & Base de données
    Réponses: 1
    Dernier message: 23/10/2008, 21h32
  3. Réponses: 2
    Dernier message: 27/05/2002, 19h46
  4. erreur IDL:omg.org/CORBA/MARSHAL:1.0
    Par Pinggui dans le forum CORBA
    Réponses: 3
    Dernier message: 13/05/2002, 15h05
  5. [Kylix] Erreur objet
    Par Anonymous dans le forum EDI
    Réponses: 1
    Dernier message: 22/03/2002, 09h41

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo