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

Multicast Receive Broken On all Unixy machines. #5657

Closed
j2man opened this Issue Mar 19, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@j2man
Copy link

j2man commented Mar 19, 2019

Environment

Logstash 6.6.2 Bundled JRuby
jruby 9.1.13.0 (2.3.3) 2017-09-06 8e1c115 Java HotSpot(TM) 64-Bit Server VM 25.162-b12 on 1.8.0_162-b12 +jit [mswin32-x86_64]

Running on:
Red Hat Enterprise Linux Workstation 7.5 (Maipo)

Expected Behavior

Call to recvfrom should not generate a socket error.

Actual Behavior

SocketError: No message available
block in ./udprcv.rb at ./udprcv.rb:14
loop at org/jruby/RubyKernel.java:1292

at ./udprcv.rb:17

Broken in:
jruby 9.1.13.0 (2.3.3) 2017-09-06 8e1c115 OpenJDK 64-Bit Server VM 25.181-b13 on 1.8.0_181-b13 +jit [linux-x86_64]

Verified that it works in this release just fine:
jruby 1.7.25 (1.9.3p551) 2016-04-13 867cb81 on OpenJDK 64-Bit Server VM 1.8.0_181-b13 +jit [linux-amd64]

Something is broken.

################## Rx Code
require 'socket'
require 'ipaddr'

MCAST_GROUP = {
:addr => '225.4.5.6',
:port => 12345,
:bindaddr => '0.0.0.0'
}

ip = IPAddr.new(MCAST_GROUP[:addr]).hton + IPAddr.new(MCAST_GROUP[:bindaddr]).h
ton
sock = UDPSocket.new
sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip)
sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEPORT, 1)
sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1)
sock.bind(Socket::INADDR_ANY, MCAST_GROUP[:port])
loop do
msg, info = sock.recvfrom(1024)
puts "MSG: #{msg} from #{info[2]} (#{info[3]})/#{info[1]} len #{msg.size}"
end

################## Tx Code
require 'socket'
MCAST_GROUP = {
:addr => '225.4.5.6',
:port => 12345,
}
s = UDPSocket.new
s.setsockopt(Socket::IPPROTO_IP, Socket::IP_MULTICAST_TTL, 1)
s.send("hello", 0, MCAST_GROUP[:addr], MCAST_GROUP[:port])

@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 8, 2019

This is fixed via #5678.

enebo added a commit that referenced this issue Apr 8, 2019

Merge pull request #5678 from jruby/recvfrom_multicast
multicast receive broken everywhere

Windows is able to bind and sendmsg but the server seems unable to recieve it (blocking by the looks of it).  Looking online and many people have issues getting multicast to work on windows.  It can be from virtual network adapters, firewall settings, address ranges, and no doubt other things.  So I am not positive this is not working based on that but until I can figure out more we can say this fixes all platforms but windows.  Even then I feel like it might work since this is pretty ordinary Java.  

As a result I am leaving windows issue open #5656 but I will be resolving #5657.

@enebo enebo changed the title Multicast Receive Broken On RHEL 7.5 Multicast Receive Broken On all Unixy machines. Apr 8, 2019

@enebo enebo added this to the JRuby 9.2.7.0 milestone Apr 8, 2019

@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 8, 2019

It is very unclear what changed here. I don't see how the implementation before #5678 could have ever worked unless the multicastsocket was something else altogether (since that classes channel is literally return null). Checked Linux (FC/Ubuntu) and MacOS. So I have not technically tried RHEL but I would be surprised if it is not fixed since it is pretty plain Java networking code. The wrinkle is that Win10 (or more specifically my win10 env) is not passing with that code so it is possible some other envs still don't work but I am optimistically resolving for all but windows.

The test in our jruby test suite is reenabled so we should not see any regressions.

@enebo enebo closed this Apr 8, 2019

@j2man

This comment has been minimized.

Copy link
Author

j2man commented Apr 8, 2019

For Windows 10:

Logstash 5.5.1 ships with:
jruby 1.7.25 (1.9.3p551) 2016-04-13 867cb81 on OpenJDK 64-Bit Server VM 1.8.0_181-b13 +jit [linux-amd64]

I have verified that it works in the 1.7.25 release just fine on windows 10 using Logstash 5.5.1

@j2man

This comment has been minimized.

Copy link
Author

j2man commented Apr 8, 2019

"...it is possible some other envs still don't work but I am optimistically resolving for all but windows."

There is another issue for the Windows side:
#5656
Maybe we can close that on if this fix works on Windows?

@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 9, 2019

Well I cannot show this fix works for windows locally on my win env so I don't know. I think it might be ok based on what the code is (e.g. it is very plain Java API code for UDP) but until I can prove that I will leave #5656 to track that. Thanks for letting us know 1.7.25 works it will be next thing to examine to see how the code differs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.