I raised a ticket for an issue in Java client library - it makes client randomly throw and abort connections when SSL and NIO mode are used - https://github.com/rabbitmq/rabbitmq-java-client/issues/317
However, there is something else I wanted to discuss which is slightly out of scope for that specific issue.For example, this is how SslEngineByteBufferInputStream gets data from the socket https://github.com/rabbitmq/rabbitmq-java-client/blob/732caded15c63032131e55f03be3e71c76bd1b57/src/main/java/com/rabbitmq/client/impl/nio/SslEngineByteBufferInputStream.java#L68-L76and the "retryRead" just tries to read from socket in a loop waiting for 100ms between iterations - https://github.com/rabbitmq/rabbitmq-java-client/blob/732caded15c63032131e55f03be3e71c76bd1b57/src/main/java/com/rabbitmq/client/impl/nio/NioHelper.java#L32-L48I see two problems:1. firs of all, 100ms is an arbitrary delay that thread will have to sleep for even if data becomes available the very next millisecond2. When retryRead fails, the SslEngineByteBufferInputStream will just throw complaining it did not receive data from the network. But it was just 300ms of waiting! What if data takes time to arrive?I understand that it is probably very difficult to trigger that condition in real life use cases but still, it is probably should not be the application-level library to make decision of what is appropriate timeout for data to be available from network. There is a whole TCP/IP stack for that.
I haven't checked code in full but I I assume this logic is there because you are using traditional (non NIO) approach when reading stuff from the socket. That is there is some code that needs to read the frame, it reads its size then reads all the necessary bytes "pulling" them from the SslEngineByteBufferInputStream. So NIO is only used to indicate when data is actually available in the socket and then, standard "synchronous" pulling starts.
I would think that NIO is supposed to be used the other way around - your network thread gets data from the socket when the data is available and passes it to some buffering reassembler whose job is to buffer these bits and pieces until a full frame can be build. Then it passes that full frame for processing and at no point you need to be polling socket trying to get more data from it. I can be wrong. of course, because I never really worked with NIO myself but this is how it reads really.
hivehome.com--Hive | London | Cambridge | Houston | TorontoThe information contained in or attached to this email is confidential and intended only for the use of the individual(s) to which it is addressed. It may contain information which is confidential and/or covered by legal professional or other privilege. The views expressed in this email are not necessarily the views of Centrica plc, and the company, its directors, officers or employees make no representation or accept any liability for their accuracy or completeness unless expressly stated to the contrary.Centrica Connected Home Limited (company no: 5782908), registered in England and Wales with its registered office at Millstream, Maidenhead Road, Windsor, Berkshire SL4 5GD.
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.