bpaquet / node-logstash

Simple logstash implmentation in nodejs : file log collection, sent with zeromq
Other
517 stars 141 forks source link

output connection to rabbitmq fails when vhost is the default / #88

Closed tomkregenbild closed 9 years ago

tomkregenbild commented 9 years ago

output connection to rabbitmq fails when vhost is not the default /

Please provide a parameter to define the vhost that the data will be sent to.

bpaquet commented 9 years ago

Do you have a stack trace ? Do you need to use the default vhost or another one ?

On Wed, Jan 21, 2015 at 10:11 AM, Tom Kregenbild notifications@github.com wrote:

output connection to rabbitmq fails when vhost is the default /

Please provide a parameter to define the vhost the data will be sent to.

— Reply to this email directly or view it on GitHub https://github.com/bpaquet/node-logstash/issues/88.

tomkregenbild commented 9 years ago

I need to use a different vhost and not the default.

In the node-logstash I get the following output: [Wed, 21 Jan 2015 09:04:38 GMT] ERROR Unable to connect [Error: Socket closed abruptly during opening handshake] [Wed, 21 Jan 2015 09:04:41 GMT] INFO Try connecting to amqps://user:pass@logstash.server:1111 retry delay 3000 [Wed, 21 Jan 2015 09:04:44 GMT] ERROR Unable to connect [Error: Socket closed abruptly during opening handshake] [Wed, 21 Jan 2015 09:04:47 GMT] INFO Try connecting to amqps://user:pass@logstash.server:1111 retry delay 3000

In the rabbitmq log I get the following error: =ERROR REPORT==== 21-Jan-2015::09:04:50 === closing AMQP connection <0.3356.9> (xx.xxx.xxx.xxx:xxxx -> yyy.yyy.yyy.yyy:yyyy): {handshake_error,opening,0, {amqp_error,access_refused, "access to vhost '/' refused for user 'user'", 'connection.open'}}

bpaquet commented 9 years ago

Mmh, are you sure about your ssl config ?

Can you run node, and type

require('amqplib/callback_api').connect(url, function() { console.log(arguments); });

where url is a correct amqp url. Can you check the connection is ok and give me the url to check node-logstash generate the correct url ?

On Wed, Jan 21, 2015 at 10:27 AM, Tom Kregenbild notifications@github.com wrote:

I need to use a different vhost and not the default.

In the node-logstash I get the following output: [Wed, 21 Jan 2015 09:04:38 GMT] ERROR Unable to connect [Error: Socket closed abruptly during opening handshake] [Wed, 21 Jan 2015 09:04:41 GMT] INFO Try connecting to amqps://user: pass@logstash.server:1111 retry delay 3000 [Wed, 21 Jan 2015 09:04:44 GMT] ERROR Unable to connect [Error: Socket closed abruptly during opening handshake] [Wed, 21 Jan 2015 09:04:47 GMT] INFO Try connecting to amqps://user: pass@logstash.server:1111 retry delay 3000

In the rabbitmq log I get the following error: =ERROR REPORT==== 21-Jan-2015::09:04:50 === closing AMQP connection (xx.xxx.xxx.xxx:xxxx -> yyy.yyy.yyy.yyy:yyyy): {handshake_error,opening,0, {amqp_error,access_refused, "access to vhost '/' refused for user 'adallom_user'", 'connection.open'}}

— Reply to this email directly or view it on GitHub https://github.com/bpaquet/node-logstash/issues/88#issuecomment-70807503 .

tomkregenbild commented 9 years ago

I think that the SSL is not the problem because I am able to reach to the rabbitmq server and you can see that the error is related to the vhost.

"access to vhost '/' refused for user 'user'",

bpaquet commented 9 years ago

This error seems to be related to your rabbitmq config.

Can you try the code in my previous message with url = 'amqp://user: pass@logstash.server:1111' and copy paste the result ?

On Wed, Jan 21, 2015 at 10:56 AM, Tom Kregenbild notifications@github.com wrote:

I think that the SSL is not the problem because I am able to reach to the rabbitmq server and you can see that the error is related to the vhost.

"access to vhost '/' refused for user 'user'",

— Reply to this email directly or view it on GitHub https://github.com/bpaquet/node-logstash/issues/88#issuecomment-70811149 .

tomkregenbild commented 9 years ago

In the rabbitmq configuration I changed the vhost from the default ' / ' to something else for security reasons. The reason for the failure is because the connection is trying to use the default vhost instead of the one I defined for my user.

In the output I see: { '0': [Error: 139972256618304:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure:../deps/openssl/openssl/ssl/s3_pkt.c:1292:SSL alert number 40 ] }

but I think it is related to the fact that I am not providing any ssl configuration in the url.

If I use the client with my configuration and change it from ssl=true to ssl=false the error in rabbitmq is different is not the error with the vhost but instead the following: =ERROR REPORT==== 21-Jan-2015::10:56:55 === error on AMQP connection <0.11421.9>: {ssl_upgrade_error,{tls_alert,"record overflow"}}

=ERROR REPORT==== 21-Jan-2015::10:56:58 === error on AMQP connection <0.11425.9>: {ssl_upgrade_error,{tls_alert,"record overflow"}}

So all I need is a parameter (it is available in the beaver logstash client) that will send the data to a different vhost and not to the default ' / '.

tomkregenbild commented 9 years ago

I now tried to create a new user in my rabbitmq server and provide it access to the ' / ' vhost and after that I was able to connect to the server with no errors.

The problem is definitely in the vhost parameter if you don't want to use the default value.