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

Close SocketChannel correctly in NIO mode #284

Closed
acogoluegnes opened this issue May 31, 2017 · 4 comments
Closed

Close SocketChannel correctly in NIO mode #284

acogoluegnes opened this issue May 31, 2017 · 4 comments
Assignees
Milestone

Comments

@acogoluegnes
Copy link
Contributor

No description provided.

@olli-miettinen-arm
Copy link

Hi, we are using amqp-client 5.2.0 and we have a healthcheck that uses the NIO enabled ConnectionFactory to create a new connection and then immediately close it. No exception is thrown to our code from the close() but this warning and either stacktrace is logged soon after. Should this be reopened?

WARN Error while closing SocketChannel

java.net.SocketException: Socket is closed
	at sun.nio.ch.Net.translateToSocketException(Net.java:121) ~[?:1.8.0_172]
	at sun.nio.ch.SocketAdaptor.setIntOption(SocketAdaptor.java:283) ~[?:1.8.0_172]
	at sun.nio.ch.SocketAdaptor.setSoLinger(SocketAdaptor.java:316) ~[?:1.8.0_172]
	at com.rabbitmq.client.impl.nio.SocketChannelFrameHandlerState.close(SocketChannelFrameHandlerState.java:220) ~[amqp-client-5.2.0.jar:5.2.0]
	at com.rabbitmq.client.impl.nio.SocketChannelFrameHandler.close(SocketChannelFrameHandler.java:99) ~[amqp-client-5.2.0.jar:5.2.0]
	at com.rabbitmq.client.impl.AMQConnection.doFinalShutdown(AMQConnection.java:717) ~[amqp-client-5.2.0.jar:5.2.0]
	at com.rabbitmq.client.impl.nio.NioLoop$1.run(NioLoop.java:290) ~[amqp-client-5.2.0.jar:5.2.0]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172]
Caused by: java.nio.channels.ClosedChannelException
	at sun.nio.ch.SocketChannelImpl.setOption(SocketChannelImpl.java:174) ~[?:1.8.0_172]
	at sun.nio.ch.SocketAdaptor.setIntOption(SocketAdaptor.java:281) ~[?:1.8.0_172]
	... 6 more

or

java.nio.channels.AsynchronousCloseException: null
	at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:205) ~[?:1.8.0_172]
	at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:478) ~[?:1.8.0_172]
	at com.rabbitmq.client.impl.nio.SslEngineHelper.close(SslEngineHelper.java:194) ~[amqp-client-5.2.0.jar:5.2.0]
	at com.rabbitmq.client.impl.nio.SocketChannelFrameHandlerState.close(SocketChannelFrameHandlerState.java:217) ~[amqp-client-5.2.0.jar:5.2.0]
	at com.rabbitmq.client.impl.nio.SocketChannelFrameHandler.close(SocketChannelFrameHandler.java:99) ~[amqp-client-5.2.0.jar:5.2.0]
	at com.rabbitmq.client.impl.AMQConnection.doFinalShutdown(AMQConnection.java:717) ~[amqp-client-5.2.0.jar:5.2.0]
	at com.rabbitmq.client.impl.nio.NioLoop$1.run(NioLoop.java:290) ~[amqp-client-5.2.0.jar:5.2.0]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172]

@michaelklishin
Copy link
Member

We won't be reopening an issue because of a warning that makes no functional difference and for which we have no steps to reproduce. A new issue would be considered as long as there are steps to reproduce.

@al81-ru
Copy link

al81-ru commented Apr 7, 2021

Hi, I got this error when combining NIO and SSL:

ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("localhost");
connectionFactory.setPort(5671);
connectionFactory.setUsername("admin");
connectionFactory.setPassword("admin");
connectionFactory.setVirtualHost("/");
connectionFactory.useSslProtocol("TLSv1.2");
connectionFactory.useNio();

Connection con = connectionFactory.newConnection();
con.close();

warn exception:

[main] WARN com.rabbitmq.client.impl.nio.SocketChannelFrameHandler - Error while closing SocketChannel
java.io.IOException: A non-blocking socket operation could not be completed immediately.
	at java.base/sun.nio.ch.SocketDispatcher.close0(Native Method)
	at java.base/sun.nio.ch.SocketDispatcher.close(SocketDispatcher.java:63)
	at java.base/sun.nio.ch.SocketChannelImpl.kill(SocketChannelImpl.java:907)
	at java.base/sun.nio.ch.SocketChannelImpl.implCloseSelectableChannel(SocketChannelImpl.java:895)
	at java.base/java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel(AbstractSelectableChannel.java:242)
	at java.base/java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:112)
	at com.rabbitmq.client.impl.nio.SocketChannelFrameHandlerState.close(SocketChannelFrameHandlerState.java:221)
	at com.rabbitmq.client.impl.nio.SocketChannelFrameHandler.close(SocketChannelFrameHandler.java:99)
	at com.rabbitmq.client.impl.AMQConnection.close(AMQConnection.java:1132)
	at com.rabbitmq.client.impl.AMQConnection.close(AMQConnection.java:1034)
	at com.rabbitmq.client.impl.AMQConnection.close(AMQConnection.java:1018)
	at com.rabbitmq.client.impl.AMQConnection.close(AMQConnection.java:1010)
	at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.close(AutorecoveringConnection.java:274)

@michaelklishin
Copy link
Member

@al81-ru comments on nearly 3 year old issues is not how issues should be reported. Please put together an executable example (e.g. using tls-gen-produced certificates), publish it on GitHub and file a new issue. Note that the exception comes from the connection closure step.

Our team routinely uses the NIO mode in this client via PerfTest and we haven't seen this before. This may be something TLS-specific but the stack trace does not suggest that at all.

We don't have any context (no platform, JVM, RabbitMQ or certificate information), and therefore cannot suggest anything.
We won't guess as guessing is a very time-consuming and expensive way of troubleshooting infrastructure.

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

No branches or pull requests

4 participants