I
I
Ivan Vekov2021-11-18 23:56:52
PHP
Ivan Vekov, 2021-11-18 23:56:52

Why am I getting an error from RabbitMQ?

The story is this, there is a service written in Laravel using GraphQL. In fact - the usual CRUD. I wanted to hang up an event for a user change mutation so that a message is sent to RabbitMQ. I have never worked with queues before, but it seems I understand the essence, read what I found, etc.

Now to the point, I call a simple code:

public function execute($message)
    {
        /**
             * Создаёт совединение с RabbitAMQP
             */
            $connection = new AMQPStreamConnection(
                'hawk.rmq.cloudamqp.com',	#host - имя хоста, на котором запущен сервер RabbitMQ
                1883,       	#port - номер порта сервиса
                'hbcittgb',    	#user - имя пользователя для соединения с сервером
                'yaCPZE87Yn1XGq_Vwmg2yQCtdYrc-MIm',     	#password
                'hbcittgb'
                );
    
                $channel = $connection->channel();

                $channel->queue_declare('hello', false, false, false, false);
                
                $msg = new AMQPMessage('Hello World!');
                $channel->basic_publish($msg, '', 'hello');
                
                $channel->close();
                $connection->close();
    }


Used this library:
https://github.com/php-amqplib/php-amqplib

PHP version is 8.0.

Rabbit put a third-party, cloudy. From here:
https://www.cloudamqp.com/

I get an error:
"The connection timed out after 3 sec while awaiting incoming data"

Well, I don't see any changes in the rabbit, respectively. What is the problem, where to dig, how to solve?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Vekov, 2021-11-19
@vekov

It turned out to be a rather stupid story, it's just that authorization on this cloud service does not seem to work. I installed rabbitmq-server on a separate VPS and everything started up without problems.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question