rabbitmq / rabbitmq-stream-go-client

A client library for RabbitMQ streams
MIT License
169 stars 20 forks source link

Can't not connect to Rabbitmq Stream via port 5552 #344

Closed LucasZhanye closed 3 months ago

LucasZhanye commented 3 months ago

Describe the bug

Firstly I follow the github description,use command: docker run -it --rm --name rabbitmq -p 5552:5552 -p 15672:15672\ -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS='-rabbitmq_stream advertised_host localhost -rabbit loopbackusers "none"' \ rabbitmq:3.9.16 to start a container. Secondly, I use golang to run this code: , err := stream.NewEnvironment( stream.NewEnvironmentOptions(). SetHost("127.0.0.1"). SetPort(5552). SetUser("guest"). SetPassword("guest").SetVHost("/")) CheckErr(err)

It always report error: 2024/07/29 10:31:25 [error] - timeout 10000 ns - waiting Code, operation: Command not handled 27 2024/07/29 10:31:25 [error] - New environment creation. Can't connect to the broker: 127.0.0.1 port: 5552. timeout 10000 ms - waiting Code, operation: Command not handled 27 exit status 1

And the Rabbitmq logs is: 2024-07-29 02:31:15.847950+00:00 [warn] <0.1230.0> unknown command {unknown,<<0,27,0,1,0,0,0,6,0,0,0,1,0,2,0,1,0,2>>}, sending close command.

Reproduction steps

  1. start a container:docker run -it --rm --name rabbitmq -p 5552:5552 -p 15672:15672\ -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS='-rabbitmq_stream advertised_host localhost -rabbit loopback_users "none"' \ rabbitmq:3-management 2.enable plugin: docker exec rabbitmq rabbitmq-plugins enable rabbitmq_stream_management
  2. run go code ...

Expected behavior

I want to connect successful

Additional context

No response

Gsantomaggio commented 3 months ago

Can you try with:

docker run -it --rm --name rabbitmq -p 5552:5552 -p 5672:5672 -p 15672:15672 \
    -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS='-rabbitmq_stream advertised_host localhost' \
    rabbitmq:3-management

then:

docker exec rabbitmq rabbitmq-plugins enable rabbitmq_stream_management

and try again using localhost

LucasZhanye commented 3 months ago

Can you try with:

docker run -it --rm --name rabbitmq -p 5552:5552 -p 5672:5672 -p 15672:15672 \
    -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS='-rabbitmq_stream advertised_host localhost' \
    rabbitmq:3-management

then:

docker exec rabbitmq rabbitmq-plugins enable rabbitmq_stream_management

and try again using localhost

I had try it, it also failed.

But I have a try, to use rabbitmq-stream-go-client v1.3.0, it is ok!

Why high version not compatibility with rabbitmq 3.9.16?

Gsantomaggio commented 3 months ago

@LucasZhanye work in progess here: https://github.com/rabbitmq/rabbitmq-stream-go-client/issues/345 Even the 3.9.16 is not supported anymore

LucasZhanye commented 3 months ago

@LucasZhanye work in progess here: #344 Even the 3.9.16 is not supported anymore

So If I still use rabbitmq server 3.9.16 (I can not change it),I can only use v1.3.0 of rabbitmq-stream-go-client?

And I have another question, I can not connect to remote rabbitmq server, maybe is about the env setting of 'advertised_host'?

How to set this env?

Gsantomaggio commented 3 months ago

With this PR you will be able to use the last version even if you won't be able to use the features like super stream etc...

Gsantomaggio commented 3 months ago

about advertised_host please read the documentation, here: the https://www.rabbitmq.com/blog/2021/07/23/connecting-to-streams