VictorGaiva / rabbitmq-stream

Elixir Client for RabbitMQ Streams Protocol.
MIT License
25 stars 3 forks source link

The connection was closed by the host | { bad_header, _} #14

Closed smahi closed 6 months ago

smahi commented 6 months ago

Hi, I am not able to use the library because of an error.

➜  rqm_demo iex -S mix

01:04:59.263 [debug] Connecting to server: localhost:5672

01:04:59.287 [debug] Connection stablished. Initiating properties exchange.
Erlang/OTP 26 [erts-14.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

01:04:59.339 [warning] The connection was closed by the host, after the socket was already open, while running the authentication sequence. This could be caused by the server not having Stream Plugin active
Interactive Elixir (1.16.2) - press Ctrl+C to exit (type h() ENTER for help)

01:04:59.285 [error] GenServer RqmDemo.MyConsumer terminating
** (stop) exited in: GenServer.call(RqmDemo.MyConnection, {:query_offset, [stream_name: "my_stream", offset_reference: "Elixir.RqmDemo.MyConsumer"]}, 5000)
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
    (elixir 1.16.2) lib/gen_server.ex:1103: GenServer.call/3
    (rabbitmq_stream 0.4.1) lib/consumer/lifecycle.ex:55: RabbitMQStream.Consumer.LifeCycle.handle_continue/2
    (stdlib 5.2) gen_server.erl:1085: :gen_server.try_handle_continue/3
    (stdlib 5.2) gen_server.erl:995: :gen_server.loop/7
    (stdlib 5.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Last message: {:continue, {:init, [credits: 50000, flow_control: {RabbitMQStream.Consumer.FlowControl.MessageCount, {:count, 1}}, offset_tracking: [{RabbitMQStream.Consumer.OffsetTracking.CountStrategy, {0, 50}}], properties: [], offset_reference: "Elixir.RqmDemo.MyConsumer", initial_credit: 50000, name: RqmDemo.MyConsumer, consumer_module: RqmDemo.MyConsumer, connection: RqmDemo.MyConnection, stream_name: "my_stream", initial_offset: :first]}}
State: %RabbitMQStream.Consumer{offset_reference: "Elixir.RqmDemo.MyConsumer", connection: RqmDemo.MyConnection, stream_name: "my_stream", offset_tracking: [{RabbitMQStream.Consumer.OffsetTracking.CountStrategy, {0, 50}}], flow_control: {RabbitMQStream.Consumer.FlowControl.MessageCount, {:count, 1}}, id: nil, credits: 50000, initial_credit: 50000, private: nil, consumer_module: RqmDemo.MyConsumer, initial_offset: :first, last_offset: 0, properties: []}

I am using the following rabbitmq server setup

$ docker run -d --hostname my-rabbit --name some-rabbit -p 8081:15672 -p 5672:5672 rabbitmq:3-management

Stream plugins are enabled

$ rabbitmq-plugins list

...
[  ] rabbitmq_stomp                     (pending upgrade to 3.13.1)
[E*] rabbitmq_stream                   3.13.1
[E*] rabbitmq_stream_management        3.13.1
[  ] rabbitmq_top                       (pending upgrade to 3.13.1)
...

Portion of rabbitmq server log

$ docker logs -f ...

2024-04-16 00:04:59.333488+00:00 [info] <0.1099.0> accepting AMQP connection <0.1099.0> (172.17.0.1:33756 -> 172.17.0.2:5672)
2024-04-16 00:04:59.334011+00:00 [error] <0.1099.0> closing AMQP connection <0.1099.0> (172.17.0.1:33756 -> 172.17.0.2:5672):
2024-04-16 00:04:59.334011+00:00 [error] <0.1099.0> {bad_header,<<0,0,0,105,0,17,0,1>>}
VictorGaiva commented 6 months ago

The correct port for RabbitMQ Stream is 5552. Port 5672 is for the AMQP Protocol. Could you please try to change it on the Connection Configuration and try again?

We can see on the AMQP logs that the connection is being opened at 5672

smahi commented 6 months ago

@VictorGaiva Oh! my bad sorry about that.

VictorGaiva commented 6 months ago

No worries. Feel free to open other issues with any other questions.

:)