Thursday, June 28, 2012

CF: ColdFusion 10 experimenting with alternate connector with IIS

If you know me, you know I really don't like the ISAPI connector Apache Tomcat has been using for ages to allow for connectivity between Apache Tomcat and IIS. This annoyed me sooo much I went to create an alternative with the BonCode connector.

When Adobe released ColdFusion 10, however, they built their connection mechanism on top of the original ISAPI connector for IIS. In addition, they made modifications to both the Tomcat server code and the ISAPI connector code to accommodate their particular needs.

The upside of this is things continue to mostly work like they have in the previous iterations, with maybe the only exception being, that you can no longer use CFFLUSH with the out of the box setup. You actually have to disable connector buffering (this has other side effects that you maybe OK with maybe not). To do so go to {CF-Home}/config/wscoonfig/{connector-no}/ Change iis_buffer_enable to false and restart the IIS.

By now you also know that Adobe does not recommend you use the default Tomcat instance to host anything else besides ColdFusion. A good blog post: "What’s the deal with Tomcat in ColdFusion 10?"  by Rupesh Kumar explains this in more detail.

On the other side, if you want to easily use one IIS to front-end multiple tomcat instances or applications, you really have to do something about the non-standard connector that ships with CF10. Your IIS gies otherwise completely monkey-crazy if you try to work with the Adobe supplied one.

Thus, time for a good experiment. I built in experimental support for the Adobe specific idiosyncrasies to the AJP protocol into the BonCode connector with version 1.0.2 and was curious whether I could get this to work with the release version of CF10.

The first step is actually to install CF10 as usual. Once the server install of CF10 is complete, however, you will need to remove the existing connector via the webserver config tool like so:

Once the removal of the Adobe connector is done, you can download the BonCode connector from RiaForge connector and start the standard install.

Accept all the defaults but once you get to the Tomcat information page, you will need to change the port to 8012 since this is the port CF10 will accept connections under for AJP, like so:

That's all folks. Now you can configure additional sites, and tomcat instances as outlined in the connector manual and your IIS server will happily serve you.

If you want to take this a little further  I would suggest a few tweaks:
a) If you want CFFLUSH support, check the appropriate option during the install of the connector on the options page.This is truly implemented as HTTP flush detection, rather than disabling of buffers and will not cause extra client or network overhead.
b) If you want the CGI.PATH_INFO variable to be populated exactly like CF10, you will need to change the connector setting file slightly. First, find out where the setting file is located by calling this URL on the server:
Then, add the PathInfoHeader directive like so to the setting file:

c) If you want to use the same packet size that Adobe defaults to, you can also change the packet size using the PacketSize directive in the setting file like so:


This reduces the number of packets exchanged between IIS and CF Tomcat but uses a larger buffer block.

d) If you want to explore the full functionality of CF10 I would also recommend that you add the wildcard mappings to the appropriate sub-folders in your  CF10 site. This is used for some of its flex and background features:


The directions on how to add wilcard mappings are also in the manual that is included in the download package for the BonCode connector.

Happy experimenting.



I added a setting specifically to address the behavior of the connector for Adobe backends with version 1.0.8 of the connector. This allows the connector to be changed with only one switch and everything should fall into place:


UPDATES: -- 5/30/2013

Adobe made changes that are only reflected in version 1.0.15 of Boncode. If you are using any earlier version you will need to change the server.xml file normally located here:


Find line similar to:
<Connector port="8012" protocol="AJP/1.3" redirectPort="8443 packetSize="65531"/>

And add the packetSize directive. This is not needed if you use version 1.0.15 or higher of connector.

UPDATES -- 01/10/2014

More time spent going through the grunge work of analysis when people reported issues more changes discovered.  For example, the Adobe connector hard-codes but hides the packetSize attribute in tomcat. Adobe is actually using 65531 bytes as packet size now. Why? No one knows.
Version 1.0.18 (to be released shortly) of the connector makes this adjustment automatically when you turn on Adobe mode so you don't get odd pages with bytes missing. This is pretty mean. I made changes accordingly to above examples.
If you use standard Tomcat, but switch to Adobe mode, you will need to put this value into the Tomcat server.xml configuration file from now on.

UPDATES -- 02/17/2014

Some hard core testing has gone into release 1.0.18g of the connector and as a result of feedback from the community I have removed the "experimental" moniker for CF10. Will support you all the way now ;o)

UPDATES -- 10/18/2014

Please note that there are some changes to the default port used for Adobe ColdFusion 11. ColdFusion 11 uses port 8014 for AJP traffic.

As usual, feedback is appreciated. Please post on the site.


Snake said...

I can;t believe Adobe didn;t test that multiple instances worked properly considering that is one the major features of enterprise edition.

Snake said...

I can;t believe Adobe didn;t test that multiple instances worked properly considering that is one the major features of enterprise edition.

Charlie Arehart said...

Hey Russ (Snake), when you refer to "multiple instances", it sounds like you are referring to instances of CF (created from the CF Admin Instance Manager). But I don't think that's what Bilal was referring to.

He said, "if you want to easily use one IIS to front-end multiple tomcat instances or applications, you really have to do something about the non-standard connector that ships with CF10."

He can clarify for us, but it seems he was referring to trying to use native Tomcat instances running CF, and trying to use the IIS/Tomcat connector that DOES come with CF.

Adobe does say that currently they do not support running CF on Tomcat (for reasons discussed in the article he points to).

I just wanted to offer clarification, as it seemed someone could misconstrue what you were asserting (whether you meant what I'm reading or not). :-)

bman said...

Indeed, I am sure Adobe did its share of testing. I am referring to the need to use one webserverver instance to connect to multiple instances of tomcat for different purposes. For example, you may have a standard tomcat instance supplying single sign with Shibboleth which also would be usefull in Coldfusion but cannot connect to them effectively with the current setup.

Snake said...

just getting around to giving this and CF10 a try. So far every wesbite I enable boncode on just resolves to C:\ColdFusion10\cfusion\wwwroot instead of the actual website.
Trying to figure out why, I presume that the jakarta vir is no longer needed when using boncode ?

bman said...

a) I am assuming that at this point that you have removed the initial Adobe connector using the website config tool.
b) You also have multiple IIS sites, each site in a different directory.
c) You ran the generic install
d) You did not make any modification to the BonCodeAJP13.setting file located in each of the BIN sub folders in your IIS site roots.
e) You are running version 1.0.15 or higher.

Then, the behavior you are describing could occur.

Point d) would be the problem in this scenario. You need to switch the connector to Adobe mode. This is the only time it will do extra work to resolve IIS virtual or changed path.

Please contact me using the project support link on RIAForge if you want to walk through your issues. I do not check blog comments frequently.

Snake said...

thanks I have emailed you as requested.
BTW, your blog doesn't seem to be sending out emails when comments are made, I didn't get a notification of your response.