我正在使用一些Java / Spring Web应用程序和RabbitMQ。
我在地址192.168.0.101
的相同 tomcat服务器上安装了App1和App2。
它们都与位于192.168.0.100
的RabbitMQ服务器进行通信。
App1在spring上下文中有这个配置:
<bean id="connectionFactory"
class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory"
destroy-method="destroy">
<property name="host" value="192.168.0.100" />
<property name="username" value="app" />
<property name="password" value="guest" />
<property name="virtualHost" value="/" />
</bean>
除了不同的用户名外,App2具有相同的配置,让我们说:
<bean id="connectionFactory"
class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory"
destroy-method="destroy">
<property name="host" value="192.168.0.100" />
<property name="username" value="app2" />
<property name="password" value="guest" />
<property name="virtualHost" value="/" />
</bean>
问题是App1可以成功连接到RabbitMQ服务器,App2在RabbitMQ日志中始终存在invalid credentials
错误。
以下是这些用户的权限列表:
Listing permissions in vhost "/" ...
app .* .* .*
app2 .* .* .*
以下是我尝试使用API登录时(包括两位用户):curl -i -u app:guest http://192.168.0.100:15672/api/whoami
和curl -i -u app2:guest http://192.168.0.100:15672/api/whoami
HTTP/1.1 401 Unauthorized
Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
Date: Mon, 30 Jun 2014 14:58:37 GMT
Content-Length: 57
{"error":"not_authorised","reason":"Not management user"}
这似乎很正常,我认为,每个用户都被认为是有效用户,但未获得管理授权。当我为app2设置管理标签时,我得到了这个:
curl -i -u app2:guest http://192.168.0.100:15672/api/whoami
HTTP/1.1 200 OK
Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
Date: Mon, 30 Jun 2014 15:14:29 GMT
Content-Type: application/json
Content-Length: 80
Cache-Control: no-cache
{"name":"app2","tags":"management","auth_backend":"rabbit_auth_backend_internal"}
我知道这是很多代码,但这就是我得到的,我即将放弃,永远不知道发生了什么。我真的不明白我做错了什么,因为配置看起来完全一样。
您怎么看?
提前致谢!很多。
编辑: 这是app2尝试连接时获得的rabbitMq日志行:
=ERROR REPORT==== 30-Jun-2014::16:42:38 ===
closing AMQP connection <0.1241.0> (192.168.0.101:52871 -> 192.168.0.100:5672):
{handshake_error,starting,0,
{amqp_error,access_refused,
"PLAIN login refused: user 'app2' - invalid credentials",
'connection.start_ok'}}
EDIT2: 这是我在app2尝试连接时获得的Java错误日志:
Caused by: com.rabbitmq.client.PossibleAuthenticationFailureException: Possibly caused by authentication failure
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:355)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:516)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:545)
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:181)
... 48 more
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; reason: java.net.SocketException: Connection reset
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:343)
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:216)
at com.rabbitmq.client.impl.AMQChannel.rpc(AMQChannel.java:202)
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:347)
... 51 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:196)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
...
答案 0 :(得分:0)
由于时间不利于我们,我决定从服务器上卸载并彻底清除Tomcat并进行全新安装,然后逐个放置每个应用程序。
猜猜是什么,他们都成功连接到RabbitMQ而没有任何警告/错误。
所以,如果有人知道特定(外部)tomcat配置如何阻止特定应用程序与RabbitMQ进行通信,那么欢迎您...
&#34;外部&#34;我的意思是&#34;不是与应用相关的&#34;组态。我不是真正的Tomcat专家,我知道有很多文件,有很多方法可以配置它,我仍然很想知道发生了什么。