-
-
Notifications
You must be signed in to change notification settings - Fork 919
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
SocketError when connecting to Unix datagram socket #6504
Comments
Could you come up with a reproduction that does not depend on systemd? This may work better on master (9.3) which has better support for Addrinfo. |
I tried using master, but got the same error, gives this stack trace:
Been banging my head against the wall trying to get The systemd socket /run/systemd/notify is always just there listening as a unix datagram socket on Ubuntu and anyone can send to it, sorry I can't seem to come up with a way to reproduce this more generally |
It looks like on Ubuntu, require 'socket'
Addrinfo.unix("/dev/log", :DGRAM).connect do |s|
s.close_on_exec = true
s.write("READY=1")
end |
The problem is that we assume dgram sockets are not UNIX sockets and always create an IP DatagramSocket for them here: jruby/core/src/main/java/org/jruby/ext/socket/RubySocket.java Lines 440 to 470 in 332dd7a
We need to have similar family-checking logic in the dgram path here. |
I have added the right pieces to do datagram things with a UnixDatagramChannel but I am not sure the actual channel is doing the right thing. I can connect now but when writing it complains about having no destination. It seems the datagram version of the Unix socket channel is not passing address, maybe? |
The systemd integration will fail for JRuby at https://github.com/puma/puma/blob/e3d5794a7ebe47577ced4d4dfdd6a6cc969ded01/lib/puma/sd_notify.rb#L140, because JRuby doesn't support UNIX datagram sockets yet, and won't for a while. See jruby/jruby#6504. So turning it off here, so that JRuby users can integrate with systemd on their own if they wish without errors.
* Don't use the systemd plugin on JRuby The systemd integration will fail for JRuby at https://github.com/puma/puma/blob/e3d5794a7ebe47577ced4d4dfdd6a6cc969ded01/lib/puma/sd_notify.rb#L140, because JRuby doesn't support UNIX datagram sockets yet, and won't for a while. See jruby/jruby#6504. So turning it off here, so that JRuby users can integrate with systemd on their own if they wish without errors. * Improved skipping systemd for JRuby Added a comment to explain the situation, and used Puma's JRuby detection method instead of re-coding it. * test that systemd plugin isn't loaded on JRuby * rename to test_plugin_systemd_jruby.rb, fix lint * rename test to test_systemd_plugin_not_loaded * make and use skip_unless :linux
* Don't use the systemd plugin on JRuby The systemd integration will fail for JRuby at https://github.com/puma/puma/blob/e3d5794a7ebe47577ced4d4dfdd6a6cc969ded01/lib/puma/sd_notify.rb#L140, because JRuby doesn't support UNIX datagram sockets yet, and won't for a while. See jruby/jruby#6504. So turning it off here, so that JRuby users can integrate with systemd on their own if they wish without errors. * Improved skipping systemd for JRuby Added a comment to explain the situation, and used Puma's JRuby detection method instead of re-coding it. * test that systemd plugin isn't loaded on JRuby * rename to test_plugin_systemd_jruby.rb, fix lint * rename test to test_systemd_plugin_not_loaded * make and use skip_unless :linux
I'm working around this for presumably the same use case for now like this: def jnr
Java::Jnr
end
module SdNotify
def self.notify(state, unset_env = false)
sock = ENV["NOTIFY_SOCKET"]
return nil unless sock
ENV.delete("NOTIFY_SOCKET") if unset_env
begin
addr = jnr.unixsocket.UnixSocketAddress.new(sock)
channel = jnr.unixsocket.UnixDatagramChannel.open
channel.send(java.nio.ByteBuffer.wrap(state.to_java_bytes), addr)
rescue StandardError => e
raise NotifyError, "#{e.class}: #{e.message}", e.backtrace
ensure
channel&.close
end
end
end |
when I run the simple script below, it works in MRI, but raises
SocketError (No message available)
in JRuby 9.2.14.0 on Ubuntu 18.04. It would be awesome to get this working so I could have my JRuby daemons communicate with systemdhere's the stack trace:
The text was updated successfully, but these errors were encountered: