Suppress java.io.IOException: Broken pipe

We frequently run into issues with Broken Pipes causing our scripts to abort, and I was looking for a way to handle these. I had opened a topic on this same issue a few months ago but never got a response, so I’m assuming there isn’t a way, so I would just like to throw out a few ideas.

To clarify on the subject of this topic; why we are encountering these errors is a matter I am still looking into, but it’s not what I’m looking to discuss here. What has been driving me nuts is that there doesn’t appear to be a way to handle these errors. As far as I can tell if this error gets thrown, the script just aborts, and there isn’t anything I can do about it. Try/Catches don’t work. There doesn’t appear to be any settings to disable it. Complete fubar.

To be clear, I understand why you would want the option to abort if the server is no longer able to send output anymore, but it really should be an option, something that I, the developer, can disable if I deem it more important to ensure the script completes, rather than just killing the script altogether.

So here are my thoughts on this

  1. Supply a flag that can be set in the script for enabling/disabling suppression of these errors. A builtin function, cfsetting suppressbrokenpipe=“boolean”, etc.

  2. Maintain a separate flag while the script is executing indicating if the pipe has been broken. If so and we attempt to send output back to the requester, it will check the flag mentioned above in no 1. If suppressbrokenpipe is currently disabled, the output is just dumped, no errors are thrown.

  3. Profit.

It would help if you did a paste bin of your code and error logs. Its hard to debug anything just from a description.

1 Like

Usually it’s on a cfflush when the error is thrown.

This appears to be the specific error.

java.io.IOException: Broken pipe


Type: org.apache.catalina.connector.ClientAbortException
Errors Reported: 1

I really wouldn’t say so. The error is telling you to take action, that is what this error is all about, not silently disable it. You need to change your settings, and if an error occurs, change it again and adapt it, so that your scripts work.

There are tons of references about this error all over the internet. Usually the problem is, because the connection between your fronted web server and your servelt engine is timing out. Just to surpress the message is a bad idea, because it clearly states that you have a connection problem and the request of YOUR scripts are taking abnormaly long. If cfflush is causing it, it may be because it is doing something to your code, or… ( what I guess is more likely ) you are using cfflush because your script already takes way tooo long, so you want to send data continiously to the client, so the client doesn’t need to wait minutes to see something happening.

I’d try to tackle the problem on the root! Rethink your strategy, e.g. do the stuff async and when it is ready present it to the client. But it’s just a guess.

Just like @Terry_Whitney already told,
it would be even better, if you would share a little bit more information of what you are trying to do with your code, a little bit more of stack trace errors and setup information, versions etc. With sooooo little information and tons of information over the internet about similar issues, it’s very likely you won’t get much help, because all we can do is just guess about what you are doing.

It’s very likely that you need to tweek your timeouts in such a manner that the connectors do not time out. But however, I even don’t know if you are using Apache, Apache2, on Linux, Windows, AJP, Reverse Proxy, IIS or whatever, we are just guessing from your little information.

In a nutshell: I’d check the timeouts on your front end and on your servlet engine and make them last longer. But changing the strategy would be more efficient, I guess.

is this happening with long running requests?

you may need to change the connector time out, default is 50s

as @andreas and @Terry_Whitney said, you need to provide better support info.

Imagine you are taking a customer support call, how would you respond to you post? You’d be asking enough questions to narrow down the problem

@jacobfw did you get any further with this issue? Hope very much you got it working somehow. Please let us know.

Both long and short. We have it getting thrown 10 seconds into a request, and 15 minutes into a request.

I’m not 100% positive what the connector timeout you’re referring to is. If it’s the same as cfsetting requesttimeout=“”, then I have and it doesn’t have any effect. I have several scripts with timeouts set for 30 minutes, and this error will get thrown a minute into it.

I’m working on getting more detailed error logs, however I can tell you from past experience, frequently the only thing I see in the exception is just it highlighting a cfflush tag, and that’s it. The stack trace stops there.

Okay here is an example.
To go ahead and answer another question.
We are using cfflush tags to output data into the response stream on a regular interval. We were already using them pretty pretty frequently, and when these errors started popping up more and more, I went in and added more, and it didn’t help.

java.io.IOException: Broken pipe


Type: org.apache.catalina.connector.ClientAbortException
Errors Reported: 4
Error: 1
Script: /var/www/html/ImportRoutines/apis/PracticePlusFIHR/npp_api_v1_main.cfm
Line Number: 193
Context:
191: <cfloop query="#aptQuery#">

192: 	<!--- <cf_api_keepalive> --->

193: 	<cfoutput>.</cfoutput><cfflush>





Error: 2
Script: /var/www/html/ImportRoutines/apis/practiceplus_api_v1.cfm
Line Number: 66

The timeout cfsetting requesttimeout="" is just one of many timeouts you can set. This timeout affects the timeout of the CFMLengine Lucee. If this times out, you’ll see a proper error thrown by Lucee and the error details will explicitly tell you that it is because of the cfsetting execution timeout. But there are more possible settings:

One important timeout is the connector timout setting in Tomcat, that you define in the connectors setting in tomcats server.xml. If you are using AJP you need add it to the AJP connector (port 8009) setting, if you are using reverse Proxy, then add it to the http connector (port 8888) setting. See this stackoverflow post. This is probably the timeout setting you need to add.

Still, we don’t know if you are using IIS or Apache as front end. I will now assume you have IIS running. It has also a timeout setting in the IIS: see this post at SO. You are not facing this timeout at the moment, but you may if you tweak the timeouts at other places. If it gets thrown, you may see an error like this

Request timed out
Exception Details: System.Web.HttpException: Request timed out.
[HttpException (0x80004005): Request timed out.]

And there is one more: the AJP connector boncode. Bilal, the creator of Boncode Connector has a great documentation about it. Go to Boncodes documentation and search for BonCode Apache Tomcat AJP 1.3 Connector". Search for the string “Setting Idle Timeouts”.

You may need to adjust them. If so, do it carefully and gradually. I would also backup everything before applying the changes.

15 mintues is pretty long time for a http request, and nobody, no human will wait sitting before a browser until its ready. Probably the browser will also time out at one moment or another. This is something I would do asynchronisly with a cfsavecontent in a cfthread or similar, create a unique deep link, and present the content to the user when its finished. Or create a static temp html or xml file, mail it, ftp it, or whatever.

1 Like