Blog

ColdFusion 11 / RESTful API / IIS URL Rewrite Issues

September 23, 2015

I recently went through a ColdFusion upgrade. We were going from version 8 to version 11. Since we had previously tested the application with ColdFusion 10 we fully expected some hiccups.

Most of the trouble encountered was easy to find and fix, however one item really gave me some trouble.

Our application has a custom API that relies on RESTful URLs. We use the IIS URL Rewrite module to map API RESTful URLs to a ColdFusion API controller page. In previous versions of ColdFusion we’d used the IIS URL Rewrite module without any issues.

When we upgraded to ColdFusion 11 our API no longer functioned and provided very little error detail. Example request:

GET /api/v1/someresource/somekey HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: http4e/5.0.12
Host: mydomain.com

Response for failed API request:

HTTP/1.1 200 OK
Content-Length: 0
Server: Microsoft-IIS/8.5
server-error: true
X-Powered-By: ASP.NET
Date: Wed, 23 Sep 2015 18:27:47 GMT

In a browser this translates to a blank screen (or white screen).

After trying many things to debug the problem (IIS Failed Request Tracing, ISAPI_Redirect logging, etc.) I was no closer to solving the problem.

From what I could gather the request was never actually making it to my API code, but instead died or failed somewhere in the rewrite process.

IIS Failed Request tracing revealed that the request was going through the URL rewrite module correctly, handing off to the ISAPI_Redirect DLL, then to the ColdFusion process as expected. A complete request with no apparent problems, other than no content and the very helpful “server-error: true” header.

I removed the URL rewrite module from the server in order to eliminate it as a problem. I could still test my code using traditional URLs.

Upon trying to access the API via a traditional URL (essentially what the URL Rewrite module would “rewrite” the URL to) I received the same 0 length response. This was my first clue that something was happening at the ColdFusion level.

Finally I was ready to give up and wanted to see if I could find any information about how others may be setting up RESTful URLs with ColdFusion 11.

The search results reminded me that starting in ColdFusion 10; Adobe began offering a built-in RESTful API to allow CFCs to be accessed directly via RESTful URLs. Could it be that the built-in RESTful API was somehow interfering with my custom RESTful API? I’d used this API setup on ColdFusion 10 with no problems, what could be different in ColdFusion 11?

The answer was a NEW mapping that ColdFusion 11 uses by default. Within the ColdFusion 11 web.xml file (Coldfusion 11: %CFUSION%\wwwroot\web.xml) there is a mapping setup for ANY request that has /api in the URL.

Renaming this default mapping resolved my issue. ColdFusion must be reset after editing the web.xml file

5 Comments

Johnny Oshika
Johnny OshikaFebruary 26, 2016 at 12:38:23 pm

Thank you for documenting this. We're using ColdFusion 10 and use the built-in REST API Service quite extensively, and recently started noticing that occasionally for unknown reasons, an endpoint (and not always the same one) stops working with the exact same response as yours. Here's an example response:

HTTP/1.1 200 OK
Content-Length: 0
Server: Microsoft-IIS/7.5
X-UA-Compatible: IE=edge,chrome=1
server-error: true
CF_TOMCAT_REUSE_THIS_CONNECTION: FALSE
X-Powered-By: ASP.NET
Date: Fri, 26 Feb 2016 17:46:01 GMT

We have no idea why this happens and it's not until we reset the REST Service does it come back up. It only happens in production and since it's random, it's very hard for us to reproduce. Our situation is a little different than yours because we are using ColdFusion's REST Services, but the result seems to be the same. I still don't have a solution for this.

Jason Holden
Jason HoldenFebruary 26, 2016 at 4:01:20 pm

@Johnny Oshika
Not sure if it applies to ColdFusion 10, but we ran into a similar issue with the default reuse setting when migrating to ColdFusion 12.

Have you tried looking at your web connnectors max reuse setting? In CF12 there is a file: {CFusion}\config\wsconfig\{instance}\workers.properties

In the file is a key: worker.cfusion.max_reuse_connections=

You'll also want to tweak these setting in that file:
worker.cfusion.max_reuse_connections=
worker.cfusion.connection_pool_size=
worker.cfusion.connection_pool_timeout=

Here's a good blog entry by Chris Tierney that explains these in more detail:

http://christierney.com/2014/12/09/max_reuse_connections-conundrum-coldfusion-11-tomcat-iis-connector/

Johnny Oshika
Johnny OshikaFebruary 28, 2016 at 2:02:38 am

Thanks so much, Jason. Strangely, I made connection changes in 2014 on my server, but when I went to look at the settings now, it's gone. Hopefully it's just confusion on my part and not something that got wiped out at some point. I reimplemented my connection pool size and max reuse connections, so I hope this solves my problem. Thanks again!

Jason Holden
Jason HoldenFebruary 28, 2016 at 8:48:09 am

@Johnny Oshika
Did you run the WSCONFIG utility at any time over the last couple of years (perhaps has part of a CF update)?

The WSCONFIG utility has wiped out my custom settings more than once.

Johnny Oshika
Johnny OshikaFebruary 29, 2016 at 12:54:16 pm

@Jason Holden, I can't remember, but that's probably what happened. Oops! :-)

Leave Your Comment

Your email address will not be published. Required fields are marked *


about me

An information technology professional with twenty five years experience in systems administration, computer programming, requirements gathering, customer service, and technical support.