Reputation: 93
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.
Everything is ok, until I try to access $client->send(new Presence);
method on the client object, after he is connected for example. This is what I get after running $client = new Client($options);
and dumping the client object that is returned in the process.
Client object dumped
But, if I run the line of code in my controller that says, for example $client->send(new Presence);
after that, I get this nasty error
XML Parsing error
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.
<?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->setUsername($username)->setPassword($password);
$client = new Client($options);
// ALL THE ABOVE CODE WORKS
$client->send(new Presence); // this or any other line below gives the XML parsing error
// optional connect manually
//$client->connect();
//$client->send(new Roster);
}
}
Upvotes: 0
Views: 888
Reputation: 4136
you must be connected and authenticated to the XMPP server before you can send a presence. Your test function does not call the connect method before you send the presence.
Upvotes: 1