Feature #1575

Java might prefer IPv6 addresses over IPv4 which prevents communication with C++

Added by J. Wienke almost 11 years ago. Updated almost 11 years ago.

Status:ResolvedStart date:07/25/2013
Priority:NormalDue date:
Assignee:J. Wienke% Done:

100%

Category:Java
Target version:rsb-0.9

Description

Solution:
  • Add a new property to prefer IPv4 and set it to true

Associated revisions

Revision 90ee0944
Added by J. Wienke almost 11 years ago

fixes #1575: Explain java IPv6 problem

History

#1 Updated by J. Wienke almost 11 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 60

I don't think there is a chance to force the use of IPv4 simply by using Inet4Addresses inside the java code. E.g. on my mac the following happens:

Jul 26, 2013 9:06:30 AM rsb.transport.socket.SocketFactory resolve
FINE: Resolved name localhost to address localhost/127.0.0.1 (Inet4Address, preferring IPv4: true)

java      8003 languitar   32u  IPv6 0x665a353cd1720e45      0t0  TCP *:55555 (LISTEN)

IPv4 connections can only be forced when using a property for the java runtime:

-Djava.net.preferIPv4Stack=true

However, I am against setting this property inside the RSB library as this would change the behavior for the whole java process and hence also for code outside of our scope with unpredictable problems in the future.

The only thing we can do is to document the behavior.

@jan: do you see other alternatives?

#2 Updated by J. Moringen almost 11 years ago

I agree and don't know of any alternatives.

We should probably look into using both, IPv4 and IPv6, in all implementations.

#3 Updated by J. Wienke almost 11 years ago

What do you mean by both? I don't know whether there actually is a chance to bind to IPv4 and IPv6 in parallel with java. With the property I indicated I can only switch from the one to the other. So at least for localhost, which is quite important, it seems to be very hard to force any specific behavior in parallel with another one.

#4 Updated by J. Moringen almost 11 years ago

Processes which act as bus clients should probably try IPv4 and IPv6 addresses when connecting. Where possible, bus servers should probably bind the IPv4 and the IPv6 for localhost or "all interfaces".

I don't know whether Java does this automatically or even supports it, but for example boost.asio needs to be explicitly instructed to use both address families.

#5 Updated by J. Wienke almost 11 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 60 to 100

Applied in changeset rsb-manual|commit:90ee0944231db94ff82ffceb5881d7c74d2c10d5.

Also available in: Atom PDF