Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Incomplete buffer response #4

Closed
flaviu-chelaru opened this issue Nov 19, 2014 · 8 comments
Closed

Incomplete buffer response #4

flaviu-chelaru opened this issue Nov 19, 2014 · 8 comments

Comments

@flaviu-chelaru
Copy link

Hello,

I've installed a local openfire server with plaintext authorization.

Authorization response is not complete, so the script triggers error.

[2014-11-19 14:07:41] xmpp.DEBUG: Received buffer '<' from 'localhost:5222' [] []
[2014-11-19 14:07:41] xmpp.DEBUG: Received buffer 'success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>' from 'localhost:5222' [] []

As you can see above, the buffer is triggered twice for the same response, and this triggers error

XML parsing error: "Not well-formed (invalid token)" at Line 1 at column 1

Adding full stack trace with error.

XML parsing error: "Not well-formed (invalid token)" at Line 1 at column 1
#0 api\vendor\fabiang\xmpp\src\Stream\XMLStream.php(160): Fabiang\Xmpp\Exception\XMLParserException::create(Resource id #317)
#1 api\vendor\fabiang\xmpp\src\Connection\Socket.php(109): Fabiang\Xmpp\Stream\XMLStream->parse('success xmlns="...')
#2 api\vendor\fabiang\xmpp\src\Connection\Socket.php(165): Fabiang\Xmpp\Connection\Socket->receive()
#3 api\vendor\fabiang\xmpp\src\EventListener\Stream\Authentication\Plain.php(66): Fabiang\Xmpp\Connection\Socket->send('<auth xmlns="ur...')
#4 api\vendor\fabiang\xmpp\src\EventListener\Stream\Authentication.php(116): Fabiang\Xmpp\EventListener\Stream\Authentication\Plain->authenticate('admin', 'admin')
#5 [internal function]: Fabiang\Xmpp\EventListener\Stream\Authentication->authenticate(Object(Fabiang\Xmpp\Event\XMLEvent))
#6 api\vendor\fabiang\xmpp\src\Event\EventManager.php(126): call_user_func(Array, Object(Fabiang\Xmpp\Event\XMLEvent))
#7 api\vendor\fabiang\xmpp\src\Stream\XMLStream.php(361): Fabiang\Xmpp\Event\EventManager->trigger('{urn:ietf:param...', Object(Fabiang\Xmpp\Stream\XMLStream), Array)
#8 api\vendor\fabiang\xmpp\src\Stream\XMLStream.php(163): Fabiang\Xmpp\Stream\XMLStream->trigger()
#9 api\vendor\fabiang\xmpp\src\Connection\Socket.php(109): Fabiang\Xmpp\Stream\XMLStream->parse('<?xml version='...')
#10 api\vendor\fabiang\xmpp\src\Connection\Socket.php(165): Fabiang\Xmpp\Connection\Socket->receive()
#11 api\vendor\fabiang\xmpp\src\Connection\Socket.php(183): Fabiang\Xmpp\Connection\Socket->send('<?xml version="...')
#12 api\vendor\fabiang\xmpp\src\EventListener\Stream\StartTls.php(100): Fabiang\Xmpp\Connection\Socket->connect()
#13 [internal function]: Fabiang\Xmpp\EventListener\Stream\StartTls->proceed(Object(Fabiang\Xmpp\Event\XMLEvent))
#14 api\vendor\fabiang\xmpp\src\Event\EventManager.php(126): call_user_func(Array, Object(Fabiang\Xmpp\Event\XMLEvent))
#15 api\vendor\fabiang\xmpp\src\Stream\XMLStream.php(361): Fabiang\Xmpp\Event\EventManager->trigger('{urn:ietf:param...', Object(Fabiang\Xmpp\Stream\XMLStream), Array)
#16 api\vendor\fabiang\xmpp\src\Stream\XMLStream.php(163): Fabiang\Xmpp\Stream\XMLStream->trigger()
#17 api\vendor\fabiang\xmpp\src\Connection\Socket.php(109): Fabiang\Xmpp\Stream\XMLStream->parse('<proceed xmlns=...')
#18 api\vendor\fabiang\xmpp\src\Connection\Socket.php(165): Fabiang\Xmpp\Connection\Socket->receive()
#19 api\vendor\fabiang\xmpp\src\EventListener\Stream\StartTls.php(80): Fabiang\Xmpp\Connection\Socket->send('<starttls xmlns...')
#20 [internal function]: Fabiang\Xmpp\EventListener\Stream\StartTls->starttls(Object(Fabiang\Xmpp\Event\XMLEvent))
#21 api\vendor\fabiang\xmpp\src\Event\EventManager.php(126): call_user_func(Array, Object(Fabiang\Xmpp\Event\XMLEvent))
#22 api\vendor\fabiang\xmpp\src\Stream\XMLStream.php(361): Fabiang\Xmpp\Event\EventManager->trigger('{urn:ietf:param...', Object(Fabiang\Xmpp\Stream\XMLStream), Array)
#23 api\vendor\fabiang\xmpp\src\Stream\XMLStream.php(163): Fabiang\Xmpp\Stream\XMLStream->trigger()
#24 api\vendor\fabiang\xmpp\src\Connection\Socket.php(109): Fabiang\Xmpp\Stream\XMLStream->parse('<?xml version='...')
#25 api\vendor\fabiang\xmpp\src\Connection\Socket.php(165): Fabiang\Xmpp\Connection\Socket->receive()
#26 api\vendor\fabiang\xmpp\src\Connection\Socket.php(183): Fabiang\Xmpp\Connection\Socket->send('<?xml version="...')
#27 api\vendor\fabiang\xmpp\src\Client.php(113): Fabiang\Xmpp\Connection\Socket->connect()
#28 api\app\commands\xmppTest.php(63): Fabiang\Xmpp\Client->connect()
#29 api\vendor\laravel\framework\src\Illuminate\Console\Command.php(112): xmppTest->fire()
#30 api\vendor\symfony\console\Symfony\Component\Console\Command\Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 api\vendor\laravel\framework\src\Illuminate\Console\Command.php(100): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 api\vendor\symfony\console\Symfony\Component\Console\Application.php(889): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 api\vendor\symfony\console\Symfony\Component\Console\Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(xmppTest), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 api\vendor\symfony\console\Symfony\Component\Console\Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 api\artisan(59): Symfony\Component\Console\Application->run()
#36 {main}

This is a Laravel Framework command
Code bellow:

public function fire() {

        try {           
            $logger = new Logger('xmpp');
            $logger->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG)); 

            $options  = new Options('localhost:5222');

            $authenticationClasses = $options->getAuthenticationClasses();
            unset($authenticationClasses['digest-md5']);            

            $options
                    ->setAuthenticationClasses($authenticationClasses)
                    ->setLogger($logger)
                    ->setUsername('admin')->setPassword('admin');

            $client = new Client($options);            
            $client->connect();       


            sleep(2);
            $client->disconnect(); 
        }catch (\Fabiang\Xmpp\Exception $ex)
        {
            print $ex->getTraceAsString();
        } catch (Exception $ex) {
            print $ex->getMessage().PHP_EOL;
            print $ex->getTraceAsString();
        }        
    }

How can i fix this?
\Thanks

@fabiang
Copy link
Owner

fabiang commented Nov 19, 2014

Not sure how to fix that. xml_parse should be able to parse this, but can reproduce this on PHP 5.3. What version are you using?

@fabiang
Copy link
Owner

fabiang commented Nov 19, 2014

Found the issue, that partial data reseted the parser. Does it work for you with the current master?

@flaviu-chelaru
Copy link
Author

Thank you for your support. This works great now.

Keep up the good work.

@fabiang
Copy link
Owner

fabiang commented Nov 20, 2014

Fixed in version 0.6.1

@Raviideal01
Copy link

I have same issue with new and old version.

@flaviu-chelaru
Copy link
Author

this issue is 2 years old. Are you sure you are on-topic here?

@Raviideal01
Copy link

Ya i am getting same issue. Please try to fix it.

On Tuesday 12 April 2016 06:57 PM, Flaviu Chelaru wrote:

this issue is 2 years old. Are you sure you are on-topic here?


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#4 (comment)

@DMeganoski
Copy link

Ravideal, Just because you are getting the same exception does not necessarily mean this is the same issue. I am also getting a "Not well-formed" error, but I know for a fact that it is unrelated to this issue.

This can be very confusing to developers, as he could waste time trying to track down a bug that doesn't exist.

If you want help with your issue, you're going to have to post more than just the exception you are getting.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants