Processing a chunked SSL response of 221 characters, I found I was waiting over 
three seconds for the entire response to be read. Upon investigation, this 
appears to be happening because the decrypt method in SSLIOSession does not 
decrypt everything in the encrypted buffer at one go. Because of this, portions 
of my response didn't get processed via the processing of the events, but 
rather via the BaseIOReactor's validate method which means I experienced 
multiple select interval timeouts prior to the message being fully processed. 
In reviewing the java nio documentation for the unwrap method of the sslEngine, 
the comments in the javadoc state: "This method will attempt to consume one 
complete SSL/TLS network packet". It appears that one time through the decrypt 
method decrypted small packets with almost no data in them, leaving encrypted 
data waiting. As an experiment, I changed the code in isAppInputReady in 
SSLIOSession to call decrypt in a loop until everything in the encrypted buffer 
was processed and bingo the response processed in under 5ms.

I was surprised not to find any other comments on this topic. Perhaps I simply 
a related topic somewhere? In any case, I'd be curious to know what the 
"correct" solution to this problem is.

Thank you very much

Scott

Reply via email to