tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: Using the Tomcat Native Library can only connect over ipv6 But not over ipv4
Date Wed, 28 Nov 2012 22:55:01 GMT
Zorro wrote:
> Op 27-11-2012 23:56, Christopher Schultz schreef:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Harm-Jan,
>>
>> On 11/27/12 3:32 PM, Zorro wrote:
>>> Op 27-11-2012 20:00, Christopher Schultz schreef:
>>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
>>>>
>>>> Harm-Jan,
>>>>
>>>> On 11/26/12 3:16 PM, Zorro wrote:
>>>>> I have now this in my server.xml: For IPv4: <Connector
>>>>> port="80" protocol="HTTP/1.1" connectionTimeout="20000"
>>>>> redirectPort="8443" address="0.0.0.0" /> For IPv6: <Connector
>>>>> port="80" protocol="HTTP/1.1" connectionTimeout="20000"
>>>>> redirectPort="8443" address="::0" />
>>>>>
>>>>> With this setup I can connect to port 80 over Ipv4 And IPv6 to
>>>>> my Linux box.
>>>> So, a recap:
>>>>
>>>> * NIO/BIO connector binds to both IPv4 and IPv6 when no "address"
>>>> is specified
>>>>
>>>> * APR connector binds only to IPv6 interface is IPv6 is
>>>> available, otherwise only IPv4
>>>>
>>>> * Linux vs. Windows is not relevant
>>>>
>>>> Do I have that all right? Or does Linux work as expected (bind to
>>>> both interfaces) and Windows does not?
>>>>
>>>> Ideally, this should work everywhere:
>>>>
>>>> <Connector port="80" protocol="HTTP/1.1" />
>>>>
>>>> ... and listen on both 0.0.0.0:80 and :::80
>>>>
>>>> The only configuration shown by Zorro has two connectors and says
>>>> that works on Windows.
>>>>
>>>>> On a Windows Vista PC I have also installed Tomcat 7.0.32 and
>>>>> the Windows installation set downloaded from tomcat.apache.org
>>>>> uses per default the Native Library. I have not changed
>>>>> anything in the configuration yet and on that PC a telnet
>>>>> 127.0.0.1 80 is ok while a IPv6 telnet ::1 80 fails.
>>>> You mean using the above configuration?
>>>>
>>>> So, you have 2 connectors on Windows and one of them doesn't work
>>>> at all? Please stop Tomcat, delete all log files, confirm your
>>>> (2-connector) configuration, start Tomcat, then re-post your
>>>> <Connector> configuration and the complete catalina.out log file,
>>>> plus versions of everything all at once.
>>>>
>>>> Better yet, if you could provide a matrix of configurations that
>>>> *do* work versus *don't* work, that would be great, too. I'm
>>>> specifically interested in knowing if this is a generic APR
>>>> problem, or only APR-on-Windows. Jeffrey Janner has had problems
>>>> on Windows (which may be a win32 TCP/IP stack problem) but if it
>>>> doesn't work on Linux, either, then perhaps it really is a bug
>>>> with APR or tcnative.
>>>>
>>>>> Maybe its worth it to include it in the documentation of the
>>>>> native library.
>>>> Maybe it's worth filing a bug report. If I can get you to
>>>> cough-up full details, it will make it much easier.
>>>>
>>>> - -chris
>>> Chris,
>>>
>>> This is what I observed. Tomcat 7.0.32
>>>
>>> 1. Linux (Fedora 14, gcc 4.5.1, OpenJDK IcedTea6 1.9.10 java
>>> version 1.6.0_20)
>>>
>>> One connector for port 80 defined without the address attribute:
>>>
>>> * NIO/BIO connector binds to both IPv4 and IPv6 when no "address"
>>> is specified * APR connector binds only to IPv6 interface if IPv6
>>> is available, otherwise only IPv4
>>>
>>> ---------
>>>
>>> 2. Windows Vista (java version 1.7.0_09)
>>>
>>> One connector for port 80 defined without the address attribute:
>>>
>>> * NIO/BIO connector binds to both IPv4 and IPv6 when no "address"
>>> is specified * APR connector binds only to IPv4 interface (not to
>>> IPv6).
>> What about when specifying two connectors, one for IPV4 and one for IPv6?
> 
> Chris, André,
> 
> Specifying 2 Connectors in the server.xml:
> For IPv4:
> <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" 
> redirectPort="8443" address="0.0.0.0"/>
> For IPv6:
> <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" 
> redirectPort="8443" address="::0"/>
> 
> 1. Linux
> 
>   * APR connector binds for IPv6 to the IPv6 Connector and for IPv4 to 
> the IPv4 Connector
> * NIO/BIO connector binds to the IPv4 Connector
> 
> For NIO/BIO the catalina.log shows exceptions:
> SEVERE: Failed to initialize end point associated with ProtocolHandler 
> ["http-bio-0:0:0:0:0:0:0:0-80"]
> java.net.BindException: Address already in use /0:0:0:0:0:0:0:0:80
>     at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:406)
>     ...
> 
> ---------
> 
> 2. Windows Vista
> 
>   * APR connector binds for IPv6 to the IPv6 Connector and for IPv4 to 
> the IPv4 Connector
> * NIO/BIO connector binds to the IPv4 Connector
> 
> For NIO/BIO the catalina.log shows exceptions:
> 28-nov-2012 21:45:55 org.apache.coyote.AbstractProtocol init
> SEVERE: Failed to initialize end point associated with ProtocolHandler 
> ["http-bio-0:0:0:0:0:0:0:0-80"]
> java.net.BindException: Address already in use: JVM_Bind 
> /0:0:0:0:0:0:0:0:80
>     at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:406)
>     ...
> 
Maybe I am interpreting this wrong, but in my view this confirms what I was trying to 
explain before (and again, I am no expert but I go by what I found by Googling).
It goes a bit along these lines (and sorry if I'm mixing up things a bit, I have a cold, 
I'm tired and want to go to bed; but I'm sure you can correct).

- On an O.S. which has a dual-capable IP stack (meaning basically : an IP stack which is 
basically IPv6, but can handle IPv4 also) :
   - java connectors, when not specifying an address, will bind to both ::0 (IPv6) and 
0.0.0.0 (IPv4) (there is no magic there, it's the IP stack who does it).
   - java connectors, when specifying an address :
       - if the address is 0.0.0.0, will bind to both ::0 and 0.0.0.0 (IPv6 and IPv4) (???)
       - if the address is ::0, will bind *only* to IPv6 (???)
    Thus, in this case, if you configure 2 connectors, both on port 80, there will be a 
conflict, because the first one binds to ::0 and 0.0.0.0, and when the second one comes 
along and tries to bind also to the same address and same port, it gets an error.

   - native connectors (like APR) should also be able to bind to both ::0 and 0.0.0.0 
simultaneously (because it's the IP stack who does it), except when you explicitly specify

an address of ::0 or 0.0.0.0. Then the connector would bind specifically only to that 
address/port.

That, in my view, explains what you see under Linux.

- On an OS which does not have a dual-capable stack, and has two separate stacks for IPv4

and IPv6 (like Windows up to Vista ?):
   - java connectors, when not specifying an address, will bind to ::0 and 0.0.0.0, by 
performing some "magic" behind the scenes, opening in fact 2 native sockets (one IPv4 and

one IPv6), but "presenting" this as one socket for the java application
   - native connectors cannot do that, and can only bind to either 0.0.0.0 or ::0 (and 
will bind to the corresponding stack).

So under Windows, the problem you see with NIO/BIO is :
   - the first connector binds to both 0.0.0.0 and ::0 (magic)
   - when the second one comes around, it can no longer bind to ::0, because it's already

taken.
   However in that case APR has no problem, because it only binds to the address (and 
stack) that you told him to.

So unfortunately it looks like for the time being, to support both IPv4 and IPv6 with all

types of connectors, one has to have different connector configurations, depending on the

OS IP stack type.

- if the OS has a dual-capable IPv6 stack, then you need only one connector,and it can be

either of NIO/BIO/APR.

- if the OS does not have a dual-capable stack then
   - for Java connectors NIO/BIO you still only need one connector, and it will do it's 
magic behind the scenes
   - for the APR connector, you need two connectors, one for 0.0.0.0 and one for ::0

Now this is either a brilliant analysis or complete crap.
I hope for the former, but I won't mind if someone has the real explanation and can 
enlighten us all.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message