title: XML parsing error: "Not well-formed (invalid token)", fabiang/xmpp PHP library package with xmpp openfire
body: <p>I've been trying to figure out why I get the "XML parsing error: "Not well-formed (invalid token)" error when trying to "send presence" to my server ( that is running localy on the same machine ), after successfully connecting a user to the server.</p>
  
  <p>Everything is ok, until I try to access <code>$client-&gt;send(new Presence);</code> method on the client object, after he is connected for example. This is what I get after running <code>$client = new Client($options);</code> and dumping the client object that is returned in the process.</p>
  
  <p><strong>Client object dumped</strong></p>
  
  <p><a href="https://i.stack.imgur.com/UYvSD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UYvSD.jpg" alt="Successfull client object"></a></p>
  
  <p>But, if I run the line of code in my controller that says, for example <code>$client-&gt;send(new Presence);</code> after that, I get this nasty error</p>
  
  <p><strong>XML Parsing error</strong></p>
  
  <p><a href="https://i.stack.imgur.com/ZIWis.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZIWis.jpg" alt="xml parsing error"></a></p>
  
  <p>The code in my controller test method is pretty simple for this, just using the guide from the documentation for the fabiang/xmpp package on packagist.</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  
  use App\Http\Requests;
  
  use Fabiang\Xmpp\Client;
  use Fabiang\Xmpp\Options;
  use Fabiang\Xmpp\Protocol\Roster;
  use Fabiang\Xmpp\Protocol\Presence;
  use Fabiang\Xmpp\Protocol\Message;
  
  class XmppController extends Controller
  {
  
      public function __construct() {
  
  
  
      }
  
      public function test() {
  
          $address = "dergree-pc:9090"; // if using HTTP in front, it will give the "cant open stream exception"
          $username = "test";
          $password = "password";
  
          $options = new Options($address);
          $options-&gt;setUsername($username)-&gt;setPassword($password);
  
          $client = new Client($options);
  
          // ALL THE ABOVE CODE WORKS
  
          $client-&gt;send(new Presence); // this or any other line below gives the XML parsing error
          // optional connect manually
          //$client-&gt;connect();
          //$client-&gt;send(new Roster);
  
  
      }
  
  }
  </code></pre>