Giter VIP home page Giter VIP logo

xmpp-php's People

Contributors

7snovic avatar norgul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xmpp-php's Issues

Fatal error: Uncaught TypeError

I get the following error while texting. Why?

Fatal error: Uncaught TypeError: Return value of Norgul\Xmpp\XmppClient::initDependencies() must be an instance of Norgul\Xmpp\void, none returned in /home/domain/public_html/src/XmppClient.php:51 Stack trace: #0 /home/domain/public_html/c2msj/src/XmppClient.php(43): Norgul\Xmpp\XmppClient->initDependencies() #1 /home/cplusxyz/public_html/index.php(19): Norgul\Xmpp\XmppClient->__construct(Object(Norgul\Xmpp\Options)) #2 /home/domain/public_html/index.php(114): Norgul\Xmpp\test('mhmtz', 'anon-a0ffd6926c...', '557b2a84cc1f64c...', 'hello') #3 {main} thrown in /home/domain/public_html/src/XmppClient.php on line 51

Reconnect on error / disconnect

I am currently using this library to build a Bot to run automation tasks.

However when it loses connectivity because either the server became unavailable or was restarted it does not automatically reconnect.

Is there a way for me to get the status and if the connection is no longer working to trigger a reconnect?

So far I have not been able to find a reliable way to do this.

Thanks!

Proxy

I can't set proxy on this function stream_socket_client;
My Code (Socket.php):

$context = stream_context_create(array(
            'http' => array(
                'timeout' => 5,
                'proxy' => 127.0.0.1:8080,
                'request_fulluri' => true
            ),
            'ssl' => array(
                'SNI_enabled' => false
            )
        ));

$this->connection = stream_socket_client($options->fullSocketAddress(), $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $context);

Is there any chance to set proxy ?

all works, but very slow

Hi
Hello
My sequence of connecting and sending a message takes about 10 seconds, how can this be accelerated?
My code is
`
$logger = new Logger('xmpp');
$logger->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));

	$options
		->setHost($hostname)
		->setPort($port)
		->setUsername($adminUsername)
		->setPassword($adminPassword)
		->setLogger(new my_logger());

	$client = new XmppClient($options);

	$client->connect();
	$client->iq->getRoster();
	$client->message->send('Hello world', 'vovan@мщмфтюсщь');
	$client->disconnect();

`
launched on same server with ejabberd.

Thanks !

ssl3_get_server_certificate:certificate verify failed

i am getting an error even with the ssl is installed on my server.

stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

Please help.

Wrong date format in logger

The "minute" format in logger is incorrect. The logs show the time as HOUR:MONTH:SECOND not HOUR:MINUTE:SECOND ;-)

re: 15/20 seconds to send a message

I saw issue #6... but not sure I fully agree with the solution. Other php clients don't have the delay.
If you set the timeout to 0 ( it is set to 1 ) in: src/Socket.php

    /**
     * Period in seconds during which the socket will be active when doing a socket_read()
     */
    protected $timeout = 0;

    /**
     * Socket constructor.
     * @param Options $options
     * @throws DeadSocket
     */
    public function __construct(Options $options)

There is no delay in sending the message.

There is an error in:
src/Buffers/Response.php
... but this:

    public function read()
    {
        if(!empty($this->response)) {
                $implodedResponse = implode('', $this->response);
                $this->flush();
                return $implodedResponse;
        } else {
                return $this->response;
        }
    }

corrects thost issues.... I don't know if this will cause issues down the line or not.

It seems like AS-IS that

    /**
     * Period in seconds during which the socket will be active when doing a socket_read()
     */
    protected $timeout = 1;

IMPOSES a 1 second delay on a socket send/read and that's not what the timeout stuff usually does. If you change that to 10.. it waits 10 seconds after each send... timeout is supposed to say wait UP TO that many seconds... not wait that many seconds.

  • jack

Resource binding before authentication

Hey, found your library and in love with the simplicity, but there is actually one issue. Trying to setup library on Symfony frramework, successfully did it, but then I'm trying to send message got this error:

Cannot bind resource before authentication

After setting TLS to TRUE, after setting resource response is "invalid-namespace" and message is not delivered.
Please fix ASAP!!

` protected static $host = 616.pub';
protected static $port = 5222;
protected static $username = 'randomas1';
protected static $password = 'randomas1';

/**
 * @Route("/", name="homepage")
 */
public function indexAction(Request $request)
{
    $options = new Options();

    $options
        ->setHost(self::$host)
        ->setPort(self::$port)
        ->setUsername(self::$username)
        ->setPassword(self::$password);

    $client = new XmppClient($options);
    $client->connect();
    $client->iq->getRoster();

    $client->message->send('Hello world', '[email protected]');

    return new Response($client->getResponse());`

List of supported XEPs

Greetings!

Do you have a list of supported XEPs?

Do you support PubSub? (i.e. XEP-0060: Publish-Subscribe)

Thanks in advance,
Schimon

Connect With Jabbim - TLS integration

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

`

<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" id="16631993638058903553" version="1.0" xml:lang="en" from="jabbim.com">
stream:features



</stream:features>



stream:error

not well-formed (invalid token)
</stream:error>
</stream:stream>
`
can you help me ?

php chat client example/suggestion

Can you advise on a tiny / simple solution that connects a website visitor with an xmpp client. Nothing fancy with audio/video/files, just a bit of writing in an overlay/pop-out window. I already have an xmpp server and an xmpp client on the desktop.

Help with simple example using Prosody xmpp server

Hi! Sorry, I am very new in this XMPP world and english is not my native language.

I am trying to send/receive messages using a Prosody xmpp server, following your basic example:

$options = new Options();
$options
    ->setHost('xmppserver.com')
    ->setPort(2700)
    ->setUsername('admin01')
    ->setPassword('password')
    ->setResource('Resource01');
$client = new XmppClient($options);
$client->connect();
$client->message->send('ping', '[email protected]');
$response = $client->getResponse();
echo '<br>'.$response;

admin01 can connect to the xmppserver.com and send the message without issues.

user01 is configured to auto-reply with a "pong" every time it receives a "ping" message.

When user01 is offline (disconnected) I receive the following response:

[email protected]/Resource01

Here is the log:

2021.05.17 18:36:22 60a2e1d495412 REQUEST::Norgul\Xmpp\Socket::send::53 <message to='[email protected]' type='normal'><body>ping</body></message>
2021.05.17 18:36:23 60a2e1d495412 RESPONSE::Norgul\Xmpp\Socket::receive::75 <message to='[email protected]/Resource01' from='[email protected]' type='error'><error type='cancel'><service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></message>

When user01 is online (connected) I receive the following response:

[email protected]/Resource01pong  // Response "pong" is in the end

Here is the log:

2021.05.17 18:38:42 60a0118ad9ae4 REQUEST::Norgul\Xmpp\Socket::send::53 <message to='[email protected]' type='normal'><body>ping</body></message>
2021.05.17 18:38:43 60a0118ad9ae4 RESPONSE::Norgul\Xmpp\Socket::receive::75 <message to='[email protected]' from='[email protected]/Resource01' type='normal' id='XMPPMessage00000007'><body>pong</body></message>

Please, I'd like to know how to check for user presence before send the message and also how to parse the message to only receive what is in the body.

Thank you very much!

Fatal error: require(): Failed opening required 'xmpp-php-master/vendor/autoload.php'

Hi, I cant to try test the Example.php, because it returns:

Warning: require(xmpp-php-master/vendor/autoload.php): failed to open stream: No such file or directory in xmpp-php-master\Example.php on line 79

Fatal error: require(): Failed opening required 'xmpp-php-master/vendor/autoload.php' (include_path='.;C:\php\pear') in xmpp-php-master\Example.php on line 79

15/20 seconds to send a message

Hi,

I need to understand what I'm doing wrong or what I need to improve in my code to speed up sending messages.

Here my PHP script:

<?php

namespace Norgul\Xmpp;

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

require __DIR__.'/vendor/autoload.php';

$options = new Options();
$options->setHost("xmpp.example.com");
$options->setPort(5222);
$options->setUsername("maria");
$options->setPassword("12345678@");

$client = new XmppClient($options);
$client->connect();
$client->iq->getRoster();

$client->message->send('Sample message', '[email protected]');

$response = $client->getResponse();
$client->prettyPrint($response);

$client->disconnect();

I can send messages, but every message takes 15 to 20 seconds to send, so I think something is wrong.

Here the log generated by the PHP script:

2019.06.10 03:06:30 5cfdf3de3f7f4 REQUEST::Norgul\Xmpp\Socket::send::57 <?xml version='1.0' encoding='UTF-8'?><stream:stream to='xmpp.example.com' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' version='1.0'>
2019.06.10 03:06:32 5cfdf3de3f7f4 RESPONSE::Norgul\Xmpp\Socket::receive::78 <?xml version='1.0'?><stream:stream id='5454702324109226903' version='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' from='xmpp.example.com' xmlns='jabber:client'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required/></starttls></stream:features>
2019.06.10 03:06:32 5cfdf3de3f7f4 REQUEST::Norgul\Xmpp\Socket::send::57 <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
2019.06.10 03:06:34 5cfdf3de3f7f4 RESPONSE::Norgul\Xmpp\Socket::receive::78 <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
2019.06.10 03:06:34 5cfdf3de3f7f4 REQUEST::Norgul\Xmpp\Socket::send::57 <?xml version='1.0' encoding='UTF-8'?><stream:stream to='xmpp.example.com' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' version='1.0'>
2019.06.10 03:06:36 5cfdf3de3f7f4 RESPONSE::Norgul\Xmpp\Socket::receive::78 <?xml version='1.0'?><stream:stream id='1254184880686051019' version='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' from='xmpp.example.com' xmlns='jabber:client'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>SCRAM-SHA-1</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
2019.06.10 03:06:36 5cfdf3de3f7f4 REQUEST::Norgul\Xmpp\Socket::send::57 <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>AG1hcmlhADEyMzQ1Njc4QA==</auth>
2019.06.10 03:06:38 5cfdf3de3f7f4 RESPONSE::Norgul\Xmpp\Socket::receive::78 <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
2019.06.10 03:06:38 5cfdf3de3f7f4 REQUEST::Norgul\Xmpp\Socket::send::57 <?xml version='1.0' encoding='UTF-8'?><stream:stream to='xmpp.example.com' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' version='1.0'>
2019.06.10 03:06:40 5cfdf3de3f7f4 RESPONSE::Norgul\Xmpp\Socket::receive::78 <?xml version='1.0'?><stream:stream id='1118384314067387153' version='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' from='xmpp.example.com' xmlns='jabber:client'><stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/><session xmlns='urn:ietf:params:xml:ns:xmpp-session'><optional/></session><c ver='M0fso8w56U7RB1HYmBkwKOuBrgw=' node='http://www.process-one.net/en/ejabberd/' hash='sha-1' xmlns='http://jabber.org/protocol/caps'/><sm xmlns='urn:xmpp:sm:2'/><sm xmlns='urn:xmpp:sm:3'/><ver xmlns='urn:xmpp:features:rosterver'/><csi xmlns='urn:xmpp:csi:0'/></stream:features>
2019.06.10 03:06:40 5cfdf3de3f7f4 REQUEST::Norgul\Xmpp\Socket::send::57 <iq type='set' id='5cfdf3e84a9bf'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>norgul_machine_1560146920</resource></bind></iq>
2019.06.10 03:06:42 5cfdf3de3f7f4 RESPONSE::Norgul\Xmpp\Socket::receive::78 <iq type='result' id='5cfdf3e84a9bf'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>[email protected]/norgul_machine_1560146920</jid></bind></iq>
2019.06.10 03:06:42 5cfdf3de3f7f4 REQUEST::Norgul\Xmpp\Socket::send::57 <presence/>
2019.06.10 03:06:44 5cfdf3de3f7f4 RESPONSE::Norgul\Xmpp\Socket::receive::78 <presence xml:lang='en' to='[email protected]/norgul_machine_1560146920' from='[email protected]/norgul_machine_1560146920'><x xmlns='vcard-temp:x:update'/></presence><presence xml:lang='en' to='[email protected]/norgul_machine_1560146920' from='[email protected]/norgul_machine_1560144963'><x xmlns='vcard-temp:x:update'/><delay from='[email protected]/norgul_machine_1560144963' stamp='2019-06-10T05:36:05.659905Z' xmlns='urn:xmpp:delay'/></presence><presence xml:lang='en' to='[email protected]/norgul_machine_1560146920' from='[email protected]/norgul_machine_1560144532'><x xmlns='vcard-temp:x:update'/><delay from='[email protected]/norgul_machine_1560144532' stamp='2019-06-10T05:28:55.324303Z' xmlns='urn:xmpp:delay'/></presence><presence xml:lang='en' to='[email protected]/norgul_machine_1560146920' from='[email protected]/norgul_machine_1560144631'><x xmlns='vcard-temp:x:update'/><delay from='[email protected]/norgul_machine_1560144631' stamp='2019-06-10T05:30:33.998640Z' xmlns='urn:xmpp:delay'/></presence><presence xml:lang='en' to='[email protected]/norgul_machine_1560146920' from='[email protected]/norgul_machine_1560144960'><x xmlns='vcard-temp:x:update'/><delay from='[email protected]/norgul_machine_1560144960' stamp='2019-06-10T05:36:02.821380Z' xmlns='urn:xmpp:delay'/></presence>
2019.06.10 03:06:44 5cfdf3de3f7f4 REQUEST::Norgul\Xmpp\Socket::send::57 <iq type='get' id='5cfdf3ec51787'><query xmlns='jabber:iq:roster'/></iq>
2019.06.10 03:06:46 5cfdf3de3f7f4 RESPONSE::Norgul\Xmpp\Socket::receive::78 <iq xml:lang='en' to='[email protected]/norgul_machine_1560146920' from='[email protected]' type='result' id='5cfdf3ec51787'><query xmlns='jabber:iq:roster'/></iq>
2019.06.10 03:06:46 5cfdf3de3f7f4 REQUEST::Norgul\Xmpp\Socket::send::57 <message to='[email protected]' type='chat'><body>Complementando mensagem para envio e tudo certo</body></message>
2019.06.10 03:06:48 5cfdf3de3f7f4 REQUEST::Norgul\Xmpp\Socket::send::57 </stream:stream>
2019.06.10 03:06:48 5cfdf3de3f7f4 RESPONSE::Norgul\Xmpp\Socket::receive::78 </stream:stream>

can't seem to send message to a groupchat.

I can do:
$client->message->send($message, $recipient,$msg_type);
where $msg_type = 'chat' and send the specified message to the specified recipient.

changing $msg_type to 'groupchat' does not get the message sent to a chat group.

You have to FIRST do something like:
$client->presence->subscribe("[email protected]/resource_name");

BUT xmpp-php sends:

<presence from='[email protected]' to='[email protected]' 
 type='subscribe' />

and that does not work for my openchat chat server. I don't get an error but when I do the send() I get a 406 error.

<error code="406" type="modify"><not-acceptable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error>

If we send:
<presence from='[email protected]' to='[email protected]' />
instead... then the send() to the chat room works.

  • jack

raspberry pi 3

I have raspberry 3. installed composer.
I run php composer.phar require norgul\xmpp-php, I get "Installation failed, deleting ./composer.json.
In RequireCommand.php line 225:
No composer.json present in the current directory (./composer.json), this may be the cause of the following exception.
In PackageDiscoveryTrait.php line 376:
Could not find a matching version of package norgulxmpp-php. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (stable).
"
I run php composer.phar create-project norgul/xmpp-php, I get "Your requirements could not be resolved to an installable set of packages.
Problem 1

  • Root composer.json requires friendsofphp/php-cs-fixer 3.0.x-dev (exact version match), found friendsofphp/php-cs-fixer[dev-master, v0.1.0, ..., v0.5.7, v1.0, ..., v1.13.3, v2.0.0-alpha, ..., v2.19.3, v3.0.0-beta.1, ..., v3.26.1] but it does not match the constraint."
    What should I do to install xmpp-php on Raspberry Pi 3?

Ability to change socket stream timeout

We are using this library to set presence on for a number of users on our XMPP server. This seems to work well but the it takes a long time to actually set. After some looking around, I found this to be caused by the following in the Socket class:

protected $timeout = 150000; // changing to 1500 significantly reduced the time taken to set all the presence
// ...
stream_set_timeout($this->connection, 0, $this->timeout);

Unfortunately, it does not seem that I can change this via the Options class.

How set status "online"

Good day.
I made changes to the Example.php file, everything works, but the status of the bot is "offline".
Please tell me how to set the status of the bot "online".

TimeOut Connect Google Hangout

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'; // [email protected]
    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', '[email protected]');
        $client->getResponse();
        do {
            $client->getResponse();
        } while (true);
    }
}

but always request time out.
can you help me ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.