viviotech / lucee-installer

BitRock Installer XML config and files for the Lucee installers
http://lucee.viviotech.net/
9 stars 2 forks source link

Remove address from ajp connector config #102

Open zspitzer opened 4 years ago

zspitzer commented 4 years ago

Specifying address=127.0.0.1 causes a 1s delay due to IPv6 resolution, removing the address let's it default to :::f and it works without a 1s delay

GaryStanton commented 4 years ago

Removing the address entirely doesn't resolve the issue for me. I must explicitly set the address to ::1 to remove the 1sec delay.

zspitzer commented 4 years ago

Does localhost work?

zspitzer commented 4 years ago

here was the bug I raised against tomcat https://bz.apache.org/bugzilla/show_bug.cgi?id=64182

GaryStanton commented 4 years ago

"RESOLVED WORKSFORME" huh? Awesome. ;) I don't have access to that box today, but I'll give 'localhost' a try as soon as I can and report back.

zspitzer commented 4 years ago

there's some further detailed discussion on the tomcat mailing list http://tomcat.10.x6.nabble.com/bind-Tomcat-to-IPv4-and-IPv6-loopback-Tomcat-9-0-31-td5096082.html

utdream commented 4 years ago

I will test this to make sure it doesn't affect anything. I don't think it will, but just in case. ;)

utdream commented 4 years ago

in my tests, removing the address field resulted in Tomcat listening to both IPv4 and IPv6 local addresses. I did not test for speed, but will take your word for it. I don't see a down side to removing this, so just going to do it.

Change will be live next release.

GaryStanton commented 4 years ago

Removing the address field still results in a 1sec delay for me. Replacing the address with 'localhost' doesn't help either. The only resolution that works for me is explicitly setting ::1 as the address.

utdream commented 4 years ago

Okay, I'll do more testing on this.

MarcAckermann commented 4 years ago

We also did a test with 'localhost' with the result of bad performance. Looks like '::1' is the only solution at the moment.

zspitzer commented 4 years ago

I'm seeing this on Windows, what platforms are others using?

GaryStanton commented 4 years ago

Windows for me. This issue is specific to the AJP connection which is being used by the Boncode connector to IIS. I don't know if the same issue occurrs with a different webserver (e.g. Apache on Windows) or on a different operating system.

zspitzer commented 4 years ago

I saw this with Apache 2.4 on Windows

utdream commented 4 years ago

So, I was able to test this on a new install of 2016 and this change made no difference in connection times on that machine. Is this still an issue for folks or has the issue been patched in other ways maybe?

Bilal-S commented 4 years ago

I got a long post on how I suck fixing this today. So, I am thinking it persist. ;o(

utdream commented 4 years ago

Lame. Sorry to hear that brother. I will do more testing. The 2016 install I used didn't have a IPv6 interface by default, so I had to create one. Even then there wasn't a difference in connection times. So, maybe it had to do with the VM or the specific install. I will play with it more and see if I can reproduce. Thank you for the feedback - if I can help with that post, let me know where it is.

andreasRu commented 4 years ago

Just an additional note: Apache shipped a server.xml with an active AJP connector tag and no address attribute until v.9.0.30. From Tomcat v.9.0.31 until latest release as of today (v9.0.35), server.xml AJP connector tag is inactive, but it has a predefined attribute address="::1" defined. The ajp-configuration docs states: "address: For servers with more than one IP address, this attribute specifies which address will be used for listening on the specified port. By default, the connector will listen on the loopback address. Unless the JVM is configured otherwise using system properties, the Java based connectors (NIO, NIO2) will listen on both IPv4 and IPv6 addresses when configured with either 0.0.0.0 or ::. The APR/native connector will only listen on IPv4 addresses if configured with 0.0.0.0 and will listen on IPv6 addresses (and optionally IPv4 addresses depending on the setting of ipv6v6only) if configured with ::."

andreasRu commented 4 years ago

Did someone try with address=0.0.0.0? This address should make the connector listen to all IPs available. I couldn't check performance in detail, because I am running a small local vmbox with just a test page, and the performance looks pretty similar. But to sum up for all, here are my findings on this VMBox with: Windows Server 2019 (10.0) 64bit Latest Apache Tomcat/9.0.35 (manual install/service installed with tomcats "service.bat install lucee") Latest Java 11.0.7 (AdoptOpenJDK) 64bit (manual install) Latest BonCodeAJP Connector Version 1.0.41 (boncode installer) Lucee 5.3.5.92

server.xml settings & TCPView results are: Setting no address attribute: Tomcat listens on 127:0:0:1:8009 IPv4 only Setting address="127.0.0.1": Tomcat listens on 127:0:0:1:8009 IPv4 only Setting address="localhost": Tomcat listens on 127:0:0:1:8009 IPv4 only Setting address="0.0.0.0": Tomcat listens on 0:0:0:0:8009 (IPv4) and 0:0:0:0:0:0:0:0:8009 (IPv6) Setting address="::1": Port listens 0:0:0:0:0:0:0:1:8009 IPv6 only Setting address="::.": Tomcat listens on 127:0:0:1:8009 IPv4 only(!?!?) Setting address="::": Tomcat listens on 0:0:0:0:8009 (IPv4) and 0:0:0:0:0:0:0:0:8009 (IPv6) Setting address="0:0:0:0:0:0:0": Tomcat listens on 0:0:0:0:8009 (IPv4) and 0:0:0:0:0:0:0:0:8009 (IPv6)

utdream commented 4 years ago

@andreasRu I tried it removed, which has a similar effect.

utdream commented 4 years ago

Vivio technicians have confirmed that this solution works in some client use cases.

Need to check to see if the installer software can detect for IPv6 interfaces and set defaults accordingly.

utdream commented 4 years ago

It appears there is a difference when the OS does not have an ipv6 interface. No interface means no 1s added latency. The ::1 solution does not function without the IPv6 interface. Need to write a script to detect if the interface is present and adjust accordingly perhaps.

carehart commented 3 years ago

Sorry to resurrect a thread from 9 months ago, but I have an update on all this that may interest at least SOME involved in this issue of dealing with the address attribute on the ajp connector line in server.xml.

If you may need a solution that works for supporting EITHER ::1 or 127.0.0.1 (which may help folks for reasons I explain in a moment), here is a solution:

you can simply to DUPLICATE the AJP connector line, and set the address attribute on each line to one of those values

I've confirmed it works, though I didn't find that clearly documented on the Tomcat config/ajp.hml page.

FWIW, I discovered this while working on a single machine (running Windows) where I found that IIS would talk to Tomcat via ipv4 (127.0.0.1) while Apache would talk to it via ipv6 (::1), even though both were set to talk to the AJP connector via localhost. That explains a lot of the confusion that I suspect many have had. Who would expect that behavior?

And this explains also why--at least in THAT case--setting the address value to 0.0.0.0 or :: won't work because again each says "I listen to all addresses on ipv4" or "on ipv6", respectively, which would still not work when a call may come into Tomcat via either ipv4 OR ipv6.

Of course, some reading this thread WILL be satisfied by just setting the one connector and its one address attribute to whatever address suits them. I just share all this as I came across this thread while trying to find a solution to this issue of running both Apache and IIS on the same machine, talking to the same tomcat, both as "localhost".

I plan to do a blog post on these things: of course it's as valuable to CFers using the Adobe web server connector/wsconfig as well as folks in this thread, Lucee folks using Boncode, and really any tomcat users using AJP. But I thought I'd shared it here first if it may interest anyone else who finds the discussion. :-)

I'd love to hear if anyone tries it--and especially if anyone somehow finds it doesn't work for them.

andreasRu commented 3 years ago

@carehart that's very interresting. Thanks for sharing. Do you know if the 1s delay issue with IIS using AJP IPv4 127.0.0.1 persists when using AJP connector in this duplicated manner? I've just installed latest stable Lucee on a brand new Windows Server 2019 box two weeks ago, and the 1s delay was still there. I had to change the AJP binding to ::1 to get rid of that delay.

carehart commented 3 years ago

Good question, @andreasRu. I did mean to clarify that I had at least confirmed that the problem of the 1s delay did NOT happen for me when I did this, as I figured folks would wonder. (Well, I added time tracking to my Apache log and didn't see a delay.) But I didn't think to first cause/confirmthe delay and then see if it went away, and I'm not readily able right now to set things up for that.

Since you CAN recreate the problem easily, I hope you will please confirm for us if this workaround does or does not "still" cause that problem.

andreasRu commented 3 years ago

@carehart just to confirm to you and others, I've added a second connector directive to the server.xml of that Windows Server 2019 box I've mentioned above and it worked. Setting one only connector directive with a binding on address="127.0.0.1" still shows a delay of about 1s, but as soon as a second connector with address="::1" is added, the delay is gone. Now watching out for your blog post about that!

carehart commented 3 years ago

Very good to hear. Thanks for the update and the encouragement. :-)

recantha commented 3 months ago

Just wanted to say that this fix is still relevant and works on Lucee 6. https://dev.lucee.org/t/lucee-performing-very-slow-compared-to-adobe-cf-site/12325/1 led me here, following a pointer from Tim Donovan at CFCamp. :-)