Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection problems with a RabbitMQ client #7851

Closed
PabloReszczynski opened this issue Dec 26, 2023 · 7 comments
Closed

Connection problems with a RabbitMQ client #7851

PabloReszczynski opened this issue Dec 26, 2023 · 7 comments
Labels
bug Something isn't working node.js Compatibility with Node.js APIs

Comments

@PabloReszczynski
Copy link

PabloReszczynski commented Dec 26, 2023

The library

node-rabbitmq-client

What version of Bun is running?

1.0.20+09d51486e

What platform is your computer?

Darwin 23.2.0 x86_64 i386

What steps can reproduce the bug?

Have a running rabbitmq service with default user/password.

In mac, it can be installed with homebrew:

brew install rabbitmq
brew services start rabbitmq

To reproduce, just start a connection with the default parameters:

// index.js
import { Connection } from "rabbitmq-client";

const rabbit = new Connection();

rabbit.on("error", console.error);
rabbit.on("connection", () => {
    console.log("Connected succesfully");
});

Package.json:

{
  "name": "bun-test-rabbitmq-client",
  "dependencies": {
    "rabbitmq-client": "^4.4.0",
  },
  "type": "module"
}

What is the expected behavior?

When running with node:

❯ node index.js
Connected succesfully

What do you see instead?

bun index.js
269 |                 ...this._opt.socket,
270 |                 ...this._opt.tls
271 |             });
272 |         }
273 |         else {
274 |             socket = node_net_1.default.connect({
                           ^
TypeError: Expected "port" to be a number between 0 and 65535
 code: "ERR_INVALID_ARG_TYPE"

      at connect (node:net:257:19)
      at _connect (/Users/p/repos/rabbitmq-example/node_modules/rabbitmq-client/lib/Connection.js:274:22)
      at new Connection (/Users/p/repos/rabbitmq-examples/node_modules/rabbitmq-client/lib/Connection.js:89:24)
      at /Users/p/repos/rabbitmq-examples/index.js:3:16

Additional information

I'm not sure when the error is happening. It could be either on the net.Socket implementation, or the way the library creates the buffers to pass to the socket.

I only know that the connection is made using net.Socket. Sorry that I can't give you more details.

@PabloReszczynski PabloReszczynski added the bug Something isn't working label Dec 26, 2023
@PabloReszczynski PabloReszczynski changed the title Connection problems with a [RabbitMQ client](https://github.com/cody-greene/node-rabbitmq-client) Connection problems with a RabbitMQ client Dec 26, 2023
@Electroid Electroid added the node.js Compatibility with Node.js APIs label Dec 26, 2023
@PabloReszczynski
Copy link
Author

Some updates: Passing the port directly as a number changes the error:

const rabbit = new Connection({
  hostname: "127.0.0.1",
  port: 5672,
  username: "guest",
  password: "guest",
});
❯ bun index.ts
4 | /** Low severity, e.g. nack'd message */
5 | class AMQPError extends Error {
6 |     code;
7 |     /** @internal */
8 |     constructor(code, message) {
9 |         super(message);
            ^
AMQPConnectionError: socket closed unexpectedly by server
 code: "CONN_CLOSE"

      at new AMQPError (/Users/p/repos/rabbitmq-example/node_modules/rabbitmq-client/lib/exception.js:9:9)
      at new AMQPChannelError (:1:33)
      at new AMQPConnectionError (:1:33)
      at /Users/p/repos/rabbitmq-example/node_modules/rabbitmq-client/lib/Connection.js:298:54
      at node:net:12:43
      at processTicksAndRejections (:61:77)

      at /Users/p/repos/rabbitmq-example/index.ts:22:3
      at node:events:2:49
      at /Users/p/repos/rabbitmq-example/node_modules/rabbitmq-client/lib/Connection.js:309:21
      at node:net:12:43
      at processTicksAndRejections (:61:77)

And in the rabbit logs I see this error:

2023-12-28 12:28:11.190378-03:00 [info] <0.14436.0> accepting AMQP connection <0.14436.0> (127.0.0.1:53924 -> 127.0.0.1:5672)
2023-12-28 12:28:14.252868-03:00 [error] <0.14436.0> closing AMQP connection <0.14436.0> (127.0.0.1:53924 -> 127.0.0.1:5672):
2023-12-28 12:28:14.252868-03:00 [error] <0.14436.0> {handshake_error,starting,28255,
2023-12-28 12:28:14.252868-03:00 [error] <0.14436.0>                  {amqp_error,frame_error,
2023-12-28 12:28:14.252868-03:00 [error] <0.14436.0>                              "type 206, all octets = <<>>: {frame_too_large,1431532544,4088}",
2023-12-28 12:28:14.252868-03:00 [error] <0.14436.0>                              none}}

Moreover, I think this may also be related to a similar issue: #5627

@tgrushka
Copy link

Yep. Having this issue. All day, and it turns out to be another Bun issue. Why would Bun have anything to do with the socket library? Is Bun trying to optimize it or something?

@DoKoB0512
Copy link

Bun uses µWebsocket under the hood. Maybe that is causing this issue.

@PabloReszczynski
Copy link
Author

Bun uses µWebsocket under the hood. Maybe that is causing this issue.

I doubt it, unless nuWebsocket is used by the bun project to implement the TCP layer. RabbitMQ uses it own protocol (AMQP) over TCP.

@PabloReszczynski
Copy link
Author

@DoKoB0512 you were partly right, Bun uses a fork of uSockets

@DoKoB0512
Copy link

I wonder why the it's closing out the connection

image

@nektro
Copy link
Contributor

nektro commented May 17, 2024

Duplicate of #4791

@nektro nektro marked this as a duplicate of #4791 May 17, 2024
@nektro nektro closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node.js Compatibility with Node.js APIs
Projects
None yet
Development

No branches or pull requests

5 participants