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

Running JRuby 9.4 and Puma with SSL #7736

Closed
treviateo opened this issue Mar 28, 2023 · 14 comments
Closed

Running JRuby 9.4 and Puma with SSL #7736

treviateo opened this issue Mar 28, 2023 · 14 comments

Comments

@treviateo
Copy link

treviateo commented Mar 28, 2023

Hi All,

I am trying to run JRuby 9.4.2.0 with ruby 3.1 and puma 5.6.5 with SSL.

System Configuration:
JRuby: 9.4.2.0
Puma: 5.6.5
Open JDK: 1.8.0_322

I downloaded the sample keystore from https://github.com/puma/puma/blob/429d17bca11f8d22dcc1434c9f6ac826a06fa836/examples/puma/keystore.jks, password blahblah. And converted it to PKCS12 format.

The keystore looks ok as following:
keystore

When running JRuby with Puma and SSL binding as following:
C:\jruby-9.4.2.0\bin\jruby.exe C:[path_to_puma]\bin\puma -b "ssl://127.0.0.1:9292?keystore=C:.ssl\keystore&keystore-pass=blahblah&verify_mode=none" -q -p 9191

the server starts up ok as following:
console1
console2

However when trying to curl (curl https://localhost:9292 -v), it failed as following:
curl

And on the server console, this error keep popping up everytime the curl command is entered:
Error reached top of thread-pool: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer; (Java::JavaLang::NoSuchMethodError)
error

Does anyone have a hunch about this and could help with this issue? Thank you.

@ahorek
Copy link
Contributor

ahorek commented Mar 28, 2023

it's a known incompatibility with binaries compiled on a newer Java, see #5499

but this has to be fixed in the Puma repo https://github.com/puma/puma/blob/master/ext/puma_http11/org/jruby/puma/MiniSSL.java#L76

for now, the easiest workaround is upgrading the Java version to 9+ if you can...

puma/puma#3108

@treviateo
Copy link
Author

Hi @ahorek, thank you for your response.

I have tried with open JDK Amazon Corretto 11.0.18 as following:
jdk
But still encountered the same issue.

For JRuby 9.4.2, I installed from the windows executable file (https://s3.amazonaws.com/jruby.org/downloads/9.4.2.0/jruby_windows_x64_9_4_2_0.exe). Just wonder whether this executable file is compiled with which version of Java? Or does it matter?

Thank you.

@ahorek
Copy link
Contributor

ahorek commented Mar 28, 2023

does jruby -v also print java 11?

either way, it's a bug and the fix should be trivial. I'm not sure if 5.6.x is still supported, it could take some time for a new release...

@treviateo
Copy link
Author

Hi @ahorek,

It seems jruby -v print out java 1.8 as following:

jruby 9.4.2.0 (3.1.0) 2023-03-08 90d2913 OpenJDK 64-Bit Server VM 25.322-b06 on 1.8.0_322-b06 +jit [x86_64-mswin32]

Tried with Puma 6.1.1 and encountered the same issue. May i know which version of Puma is good to try ?

Thank you.

@ahorek
Copy link
Contributor

ahorek commented Mar 28, 2023

could you test puma/puma#3109 ?

gem "puma", git: "https://github.com/ahorek/puma.git", branch: "java8"

@treviateo
Copy link
Author

Hi @ahorek,

Try to run bundle install after adding gem 'puma', git: 'https://github.com/ahorek/puma.git', branch: 'java8' and encountered the attached error:
puma_build_error.txt

Did i miss anything? Thank you.

@ahorek
Copy link
Contributor

ahorek commented Mar 28, 2023

ahh, Puma doesn't support building the JRuby version directly from the git repo. Never mind, here's a manual build:
https://github.com/ahorek/puma/blob/build/puma-6.1.1-java.gem

gem install puma-6.1.1-java.gem

@treviateo
Copy link
Author

Hi @ahorek,

Adding this line on Gemfile:
gem 'puma', source: 'https://github.com/ahorek/puma/blob/build/puma-6.1.1-java.gem'

and bundle install run ok with Gemfile.lock looks as this:
GEM
remote: https://github.com/ahorek/puma/blob/build/puma-6.1.1-java.gem/
specs:
puma (6.1.1-java)
nio4r (~> 2.0)

Puma output on startup:
puma6 1 1
ssl
However still encounter the same issue on curl https://127.0.0.1:9292 -v
Error reached top of thread-pool: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer; (Java::JavaLang::NoSuchMethodError)
error_puma_6 1 1

Thank you.

@ahorek
Copy link
Contributor

ahorek commented Mar 29, 2023

ok, but it's a different place, maybe there's another gem with the same issue? (not clear where it comes from without a proper backtrace)

I suspect it could be nio4j, basically the same story:
https://github.com/socketry/nio4r/blob/main/ext/nio4r/org/nio4r/ByteBuffer.java#L59
https://github.com/socketry/nio4r/blob/main/rakelib/extension.rake#L7

@treviateo
Copy link
Author

Hi @ahorek,

Are you a contributor for nio4r as well ? If you do, may you help to fix it there as well ?

Thank you, really appreciate your help.

@kares kares added this to the Invalid or Duplicate milestone Mar 29, 2023
@ahorek
Copy link
Contributor

ahorek commented Apr 3, 2023

@treviateo both puma & nio4j have been released with compatibility fixes. Could you test it again if you still getting the same error?

@treviateo
Copy link
Author

Hi @ahorek,

Thank you for your reply. Just updated to puma 6.2.1, but still encounter the issue when trying to curl https://127.0.0.1:9292 -v or access the url https://localhost:9292 from browser:

puma_6 2 1_ssl_error

Gemfile.lock snippet:
gemfile_lock_snippet

Curl error:
curl_error

Please let me know if you notice something that I probably miss. Thank you.

@ahorek
Copy link
Contributor

ahorek commented Apr 4, 2023

we need a more verbose backtrace. What gem is using the bytebuffer and where. It could also be some piece of code in JRuby itself. I'll see if I can simulate the issue tomorrow.

@ahorek
Copy link
Contributor

ahorek commented Apr 5, 2023

fixed by #7742

@ahorek ahorek closed this as completed Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants