John Davidson

Connection to the RabbitMQ doesn't work only in PHP

0 comments
Message:


I'm trying to connect to the rabbit queue.
For some reason, example from the documentation doesn't work(only in PHP for some reason)


Library


amqplib/php-amqplib

PHP code that doesn't work:


$connection = new AMQPStreamConnection(
'test.cloudamqp.com',
5671,
'test',
'test',
'test'
);

I receive the next errors:



PHP Fatal error: Uncaught
PhpAmqpLib\Exception\AMQPConnectionClosedException: Broken pipe or
closed connection in
/home/mykola/Projects/vs-php-clipping-engine/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php:172
Stack trace:
#0 /home/mykola/Projects/vs-php-clipping-engine/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php(158):
PhpAmqpLib\Wire\IO\StreamIO->read()
#1 /home/mykola/Projects/vs-php-clipping-engine/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php(104):
PhpAmqpLib\Wire\AMQPReader->rawread()
#2 /home/mykola/Projects/vs-php-clipping-engine/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php(576):
PhpAmqpLib\Wire\AMQPReader->read()
#3 /home/mykola/Projects/vs-php-clipping-engine/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php(632):
PhpAmqpLib\Connection\AbstractConnection->wait_frame()
#4 /home/mykola/Projects/vs-php-clipping-engine/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php(235):
PhpAmqpLib\Connection\ in
/home/mykola/Projects/vs-php-clipping-engine/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php on line 172



Golang code that works perfectly:


package main

import (
"log"

amqp "github.com/rabbitmq/amqp091-go"
)

func failOnError(err error, msg string) {
if err != nil {
log.Panicf("%s: %s", msg, err)
}
}

func main() {
conn, err := amqp.Dial("amqps://test:[email protected]/test")
failOnError(err, "Failed to connect to RabbitMQ")
defer conn.Close()

}

Does a golang package have some magic parameters that are automatically applied to this connection
I'm thinking maybe I need some specific arguments to pass.



My Answer:
RabbitMQ is a message broker software that allows different components of a system to communicate with each other by sending and receiving messages. It is commonly used in distributed systems to decouple different parts of the system and improve scalability and reliability.

To connect to RabbitMQ, you typically need to use a client library that supports the AMQP (Advanced Message Queuing Protocol) protocol, which RabbitMQ uses for communication. The client library will provide you with methods to publish messages to exchanges, consume messages from queues, and manage connections and channels to the RabbitMQ server.

Once you have established a connection to RabbitMQ, you can start sending and receiving messages between different components of your system. This allows you to build a robust and scalable architecture that can handle large volumes of data and ensure reliable communication between different parts of your system.

Rate this post

5 of 5 based on 8942 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us