xmppo / xmpp-php

PHP client library for XMPP (Jabber) protocol
https://github.com/xmppo/xmpp-php
MIT License
45 stars 23 forks source link

Connect With Jabbim - TLS integration #3

Closed jrpikong closed 5 years ago

jrpikong commented 5 years ago

Hi @Norgul I'm back, I use the last version . I can't connect with jabbim.com Screenshot from 2019-04-16 17-02-09 Screenshot from 2019-04-16 17-01-51

` <?xml version="1.0" encoding="UTF-8"?>

not well-formed (invalid token) ` can you help me ?
Norgul commented 5 years ago

Sure, I will take a look and get back at you

Norgul commented 5 years ago

It looks like Jabbim uses TLS which I didn't yet implement in the library. I will do that and inform you once done

Norgul commented 5 years ago

Hello @jrpikong, can you try out the new version 2.1.0?

Along with your options just add setTls(true) so that it looks like this

$options
    ->setHost(self::$host)
    ->setPort(self::$port)
    ->setUsername(self::$username)
    ->setPassword(self::$password)
    ->setTls(true);
Norgul commented 5 years ago

@jrpikong I am closing the issue as the feature is implemented. Let me know if there is anything else needed. Thanks

jrpikong commented 5 years ago

Hi @Norgul I have new error if I try to use TLS

namespace Norgul\Xmpp;
class Example
{
    protected static $host     = 'jabbim.com';
    protected static $port     = 5222;
    protected static $username = 'deny123@jabbim.com';
    protected static $password = 'password213';
    public static function go()
    {
        $options = new Options();
        $options
            ->setHost(self::$host)
            ->setPort(self::$port)
            ->setUsername(self::$username)
            ->setPassword(self::$password)
            ->setUseTls(true);
        $client = new XmppClient($options);
        $client->connect();
        $client->iq->getRoster();
        $client->message->send('Hello world', 'smtel_001@jabbim.com');
        // Uncomment if you want to manually enter raw XML (or call a function) and see a server response
//        (new self)->sendRawXML($client);
        do {
            $response = $client->getResponse();
            $client->prettyPrint($response);
        } while (true);
        $client->disconnect();
    }
}

and This the response :

sniper@sniper:~/Projects/smtel/jabber$ php Example.php 
PHP Warning:  Module 'curl' already loaded in Unknown on line 0
PHP Warning:  fwrite(): SSL operation failed with code 1. OpenSSL Error messages:
error:1420C0CF:SSL routines:ssl_write_internal:protocol is shutdown in /home/sniper/Projects/smtel/jabber/vendor/norgul/xmpp-php/src/Socket.php on line 53
Norgul commented 5 years ago

Hello @jrpikong, which version are you using?

Norgul commented 5 years ago

Response from server I'm getting is the following:

<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
    <not-authorized/>
    <text xml:lang='en'>Invalid username or password</text>
</failure>

Are you sure credentials are okay?

Btw, if you download the new version (v2.1.6) you can get rid of setUseTls(true) argument. TLS (if supported by server) is now enabled by default