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

how-to DEBUG mode investigate connection issues #5

Open
kmacpher67 opened this issue Oct 28, 2019 · 6 comments
Open

how-to DEBUG mode investigate connection issues #5

kmacpher67 opened this issue Oct 28, 2019 · 6 comments

Comments

@kmacpher67
Copy link

kmacpher67 commented Oct 28, 2019

Migrating from native "amqplib": "^0.5.2" to log4js.
Getting error on the connection socket.
We have ssl enabled and process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

 ERR { Error: Socket closed abruptly during opening handshake
 ERR     at Socket.endWhileOpening (/app/node_modules/amqplib/lib/connection.js:260:17)
 ERR     at Socket.emit (events.js:203:15)
 ERR     at endReadableNT (_stream_readable.js:1129:12)
 ERR     at process._tickCallback (internal/process/next_tick.js:63:19)

the config.rabbit is:

var rabbit = {
    type: '@log4js-node/rabbitmq',
    host: '127.0.0.1',
    port: 5672,
    username: 'guest',
    password: 'guest',
    routing_key: 's.system.log',
    exchange: 's.exchange.infrastructure.logger',
    mq_type: 'topic',
    con: {heartbeat: 30, protocol: 'amqps'}
  }````


@nomiddlename
Copy link
Contributor

Looks like the server is expecting a client certificate, but you're not supplying one. Which makes sense, because the appender doesn't know anything about SSL at the moment. It doesn't look like much work to add support for it going by the SSL Guide, (just pass a connection options object as the second argument to the connect call) but I don't have the expertise to work on this. Happy to see a PR that implements it though.

@nomiddlename
Copy link
Contributor

If you want to investigate this, then take a look at the integration.sh script in the test directory. It starts up a docker container running rabbitmq, then tries to connect to it using the node code. You could replace the docker image with one configured to run the same as the server you're trying to connect to.

@kmacpher67
Copy link
Author

i created a fork for enabling:
const protocol = config.protocol || 'amqp';
https://github.com/kmacpher67/rabbitmq
I added other variables too whilst in there.
I did not add any tests.

@kmacpher67
Copy link
Author

#12
did some minor clean up let me know.

@kmacpher67
Copy link
Author

ahh, incase anybody was interested. It's pretty simple.
export DEBUG=log4js* # shows all debug statements for log4js
export DEBUG=log4js:rabbitmq* # shows only debug for rabbitmq appender

@kmacpher67
Copy link
Author

Gareth Jones nomiddlename:
So the tap tests are failing, because they are expecting results back from amqp open (parameters).
Instead to get SSL working, I had to reconfigure the URL instead:

const socketOptions = con;
    amqplib.connect(url, socketOptions).then((c)

IMHO if i'm changing test code then this is non-trivial change.
I've never done node tap component tests (The fake mocks are voodoo tome) not that I can't figure it out, but when I do, are we still going to get a MR completed?
Let me know before I invest any further time on getting this branch to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants