stomp-php / stomp-php

Stomp PHP Client
https://github.com/stomp-php/stomp-php/wiki
Apache License 2.0
125 stars 57 forks source link

Can't see proper error messsage #168

Open chandra10207 opened 2 years ago

chandra10207 commented 2 years ago

I am using ActiveMQ on AmazonMQ as a broker.

When I try to connect, It always shows the exemption message "Unable to connect broker". I am not sure is it an issues with logins or port?

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

use Stomp\Client;
use Stomp\Network\Connection;
use Stomp\StatefulStomp;
use Stomp\Transport\Message;
use Stomp\Exception\ConnectionException;
use Stomp\Network\Observer\HeartbeatEmitter;
use Stomp\Transport\Frame;
use Stomp\Exception\StompException;
use Stomp\Stomp;

$brokerUri = '....';
$connection = new Connection($brokerUri);
$client = new Client($connection);
$client->setLogin($username, $pass);
// connect
try {
    $client->connect();
} catch (ConnectionException $e) {
    echo "Connections ERROR: \n". PHP_EOL;
    echo $e->getMessage() . PHP_EOL;;
}

Is there anything I am missing?

whikloj commented 10 months ago

I don't see anything immediately. You could try passing the brokerUrl directly to the Client constructor and avoid creating your own Connection, but that shouldn't really be a problem. I'd try to get this working with a local ActiveMQ broker and once that is working you can try Amazon again.