xmppo / xmpp-php

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

TimeOut Connect Google Hangout #2

Open jrpikong opened 5 years ago

jrpikong commented 5 years ago

Hi @Norgul , I use your library and I try to connect with Google Hangout with this config

use Norgul\Xmpp\Options;
use Norgul\Xmpp\XmppClient;

class XmppController extends Controller
{
    protected static $host     = 'gmail.com';
    protected static $port     = 5222;
    protected static $username = 'user_gmail'; // user_gmail@gmail.com
    protected static $password = 'password_gmail';
    public function __construct()
    {
        ini_set('display_errors', 1);
        ini_set('display_startup_errors', 1);
        error_reporting(E_ALL);
    }
    public function getMessage()
    {
        $options = new Options();
        $options
            ->setHost(self::$host)
            ->setPort(self::$port)
            ->setUsername(self::$username)
            ->setPassword(self::$password);
        $client = new XmppClient($options);
        $client->connect();
        $client->getRoster();
        $client->sendMessage('Hello world', 'test@jabber.com');
        $client->getResponse();
        do {
            $client->getResponse();
        } while (true);
    }
}

but always request time out. can you help me ?

Norgul commented 5 years ago

Hi @jrpikong would you mind telling me what version of the library are you using?

jrpikong commented 5 years ago

Hi @Norgul thank for your fast response, this my version : "norgul/xmpp-php": "^1.1",

Norgul commented 5 years ago

@jrpikong first thing to notice is that you are using wrong host. For Google hangouts, the host should be talk.google.com.

As for the timeout, I am pretty sure Google has some better verification system besides PLAIN :) This is something I will need to take on and research, and implement new verification which can pass Google security issues.

On the side note, I tried to register myself to XMPP over Adium (it is like Pidgin, but for Mac) with my Google credentials and couldn't do so until I have enabled less secure apps in my Google account.

I'll get on it these days and try to make it work. You are also free to check out and contribute if you have some ideas.

jrpikong commented 5 years ago

I will wait dude

Norgul commented 5 years ago

Hello again @jrpikong, if you'd like to see the output of the library, you can forward a flag to $client->getResponse() method ($client->getResponse(true)).

I have tried again (with talk.google.com host) and what I get is the following response:

HTTP/1.1 301 Moved Permanently Location: https://hangouts.google.com/

Even though some people say it is (was) possible to connect to the server, and even though I didn't implement TLS I am not sure at this point that I got the real host.

Still on it, but if you find out something useful I'd appreciate if you wrote it here. Thanks

Norgul commented 5 years ago

I am closing this issue as I didn't found any resource pointing me in the right direction. oAuth2 may be implemented in future releases

Norgul commented 5 years ago

I am reopening this issue. I had a bug (resolved now) which disabled the communication with google servers. Right host is talk.l.google.com. I will look to implement Google auth in the next release