在windows服务器装了一个rabbitmq消息中间件,在项目中进行远程连接时,当一段时间没有使用,项目中一直出现如下异常,一旦你进行消息发送又不能够正常工作,这个异常不影响使用,但是具体存在什么隐患我也不清楚:
[SimpleAsyncTaskExecutor-9] WARN [org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer] - Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection timed out: connect
[SimpleAsyncTaskExecutor-9] INFO [org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer] - Restarting Consumer: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
ERROR [org.springframework.amqp.rabbit.connection.CachingConnectionFactory] - Channel shutdown: connection error; protocol method: #method<connection.close>(reply-code=320, reply-text=CONNECTION_FORCED - broker forced connection closure with reason 'shutdown', class-id=0, method-id=0)
ERROR [org.springframework.amqp.rabbit.connection.CachingConnectionFactory] - Channel shutdown: connection error; protocol method: #method<connection.close>(reply-code=320, reply-text=CONNECTION_FORCED - broker forced connection closure with reason 'shutdown', class-id=0, method-id=0)
[SimpleAsyncTaskExecutor-10] WARN [org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer] - Consumer raised exception, processing can restart if the connection factory supports it
com.rabbitmq.client.ShutdownSignalException: connection error; protocol method: #method<connection.close>(reply-code=320, reply-text=CONNECTION_FORCED - broker forced connection closure with reason 'shutdown', class-id=0, method-id=0)
at com.rabbitmq.client.impl.AMQConnection.startShutdown(AMQConnection.java:715)
at com.rabbitmq.client.impl.AMQConnection.shutdown(AMQConnection.java:705)
at com.rabbitmq.client.impl.AMQConnection.handleConnectionClose(AMQConnection.java:660)
at com.rabbitmq.client.impl.AMQConnection.processControlCommand(AMQConnection.java:615)
at com.rabbitmq.client.impl.AMQConnection$1.processAsync(AMQConnection.java:107)
at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:144)
at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:91)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:540)
at java.lang.Thread.run(Thread.java:745)
在远程连接时出现此问题,查询网上资料说rabbitmq在单机情况下都是长连接,我这也并没有使用集群,考虑会不会是新建用户并授权后,但是远程连接有限制一定时间后对于不活动的客户端连接会自动断开连接,抱着试试的心态,找到rabbitmq.config,设置{loopback_users, ["username"]} 引号内是用户名,如果是对所有用户就置空就行
%% The default "guest" user is only permitted to access the server
%% via a loopback interface (e.g. localhost).
%% {loopback_users, [<<"guest">>]},
%%
%% Uncomment the following line if you want to allow access to the
%% guest user from anywhere on the network.
%% {loopback_users, []}, --注意下面没有元素是逗号不要
然后通过命令stop停止rabbitmq服务器并install重装服务,再start启动,客户端再没有出现这个异常问题了,特此记录一下备忘