Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby-OSSL 0.7.1
-
Fix Version/s: JRuby-OSSL 0.7.2
-
Component/s: OpenSSL
-
Labels:None
-
Environment:Mac and Ubuntu
-
Number of attachments :
Description
We had an outside supplier go down which resulted in our Net::HTTP connections to them locking up for several minutes. We had these connections wrapped up in a timeout block which seemed to not correctly timeout after the requested time. This resulted in all of our glassfish connections that were handling requests to become locked up as well which basically brought our site down.
I wrote the attached test program to figure out exactly what was going on. You will need to create a dummy cert and key to use it. Here's how I did it:
openssl genrsa 1024 > host.key
chmod 400 host.key
openssl req -new -x509 -nodes -sha1 -days 365 -key host.key > host.cert
When run with an http connection, the tests worked as expected. open_timeout seemed to be completely ignored for both MRI and JRuby but maybe I misunderstand what its supposed to do.
When run with an https connection under JRuby, read_timeout and Timeout blocks don't actually timeout until after the read is complete. This means that even if you wrap your request in a Timeout.timeout(3) block, if the connection takes 5 minutes then thats how long it will take for your Timeout error to get raised. This works as expected under MRI.
Note for myself: JRuby-OSSL uses own Selector now. It should use RubyThread#select or (at least) do call #pollThreadEvents to be killed by another Thread. (timer thread for this problem)