Overview of the Problem
A cfhttp timeout occurs when a ColdFusion
Why it happens:
- The remote server is slow or unavailable.
- Network path or firewall delays block or throttle traffic.
- DNS lookups are slow or failing.
- SSL handshake issues stall the connection.
- ColdFusion or JVM timeouts are misconfigured.
- Large payloads or concurrency spikes exhaust resources.
When diagnosing
What a cfhttp Timeout Means
- Connection timeout: The client cannot establish a TCP connection to the remote host within the allowed time.
- Read (socket) timeout: The connection is established, but no data is received for the allowed time while waiting for response bytes.
- Request timeout (ColdFusion Request lifecycle): The entire CFML request exceeds the configured execution time.
- Proxy timeout: A configured proxy server delays or drops the connection.
In many stacks, “timeout” is a read timeout by default. ColdFusion’s
Possible Causes
- Slow or busy remote API/service.
- Network congestion, packet loss, or firewall rules.
- DNS latency, faulty DNS servers, or incorrect hostnames.
- SSL/TLS negotiation failures or unsupported ciphers/protocols.
- Proxy server bottlenecks or wrong proxy settings.
- ColdFusion request timeout shorter than
needs. - Too many concurrent outbound calls (resource exhaustion).
- Large uploads/downloads, chunked encoding issues, or streaming mishandling.
- JVM or OS-level constraints (ephemeral ports, TCP time-wait, DNS caching).
Step-by-Step Troubleshooting Guide
1) Confirm it’s a real timeout and capture details
- Check exception types and message text in logs:
- java.net.SocketTimeoutException: Read timed out
- java.net.ConnectException: Connection timed out
- java.net.UnknownHostException
- javax.net.ssl.SSLHandshakeException
Example ColdFusion logs excerpt:
ERROR coldfusion.tagext.net.HTTPTag – I/O Exception: java.net.SocketTimeoutException: Read timed out
at org.apache.http.conn.EofSensorInputStream.read(…)
URL: https://api.example.com/v1/data
- Log the
result structure for clues:
or minimally:
<cflog file=”http-timeouts” type=”information”
text=”StatusCode=#cfhttp.StatusCode#, ElapsedTime=#cfhttp.ElapsedTime#, ErrorDetail=#cfhttp.ErrorDetail#”>
- Determine if the timeout happens on all requests or only under load.
2) Reproduce and isolate the path
- Call the same URL with curl/Postman from the ColdFusion server:
curl -v –connect-timeout 5 -m 20 https://api.example.com/v1/data
- If curl works instantly but CFHTTP times out, the problem is likely CF/JVM config, proxy, SSL, or app code.
- If curl also times out, you’re facing a network/remote endpoint problem.
3) Check ColdFusion-level time limits
- Request timeout (CF Administrator > Server settings > Request Tuning):
- If requests time out globally at, say, 30s, any long
call will be cut off.
- If requests time out globally at, say, 30s, any long
- Per-request override:
- cfhttp timeout attribute (controls how long to wait for a response):
<cfhttp url=”https://api.example.com/v1/data”
method=”get”
timeout=”60″
resolveURL=”false”
throwOnError=”true”
result=”resp” />
- Ensure your requesttimeout setting is >= your
timeout, or the overall request may end first.
Note: Timeout semantics can vary by CF engine/version. In some engines, timeout primarily governs socket read time; connection timeout may be distinct or inherited from defaults.
4) Inspect CFHTTP code and attributes
- Use resolveURL=”false” unless you specifically need URL rewriting of returned HTML. This saves time on content parsing.
- Use path/file to stream large responses to disk instead of memory:
<cfhttp url=”https://large.example.com/file.zip”
method=”get”
timeout=”120″
getAsBinary=”yes”
path=”D:\downloads”
file=”file.zip”
result=”resp” />
- If using a proxy, ensure correct settings:
<cfhttp url=”https://api.example.com”
proxyServer=”proxy.mycorp.local”
proxyPort=”8080″
proxyUser=”svc-account”
proxyPassword=”****”
timeout=”30″
result=”resp” />
- For POST/PUT with large bodies, use cfhttpparam and consider compression and chunking support on the server:
5) Test the target endpoint independently
- Validate the endpoint health and response times using:
- curl: measure time_total, time_connect
curl -w “connect: %{time_connect}s, total: %{time_total}s\n” -o /dev/null -s https://api.example.com/v1/data
- Ask the remote provider for current status, rate limits, or throttling policies.
If the remote is slow, your only safe fix is to increase timeouts or use async patterns (cfthread, message queue) and retries with backoff.
6) Investigate network path and DNS
- DNS resolution:
- Try resolving host:
nslookup api.example.com
- Test with direct IP (for Troubleshooting only; beware SNI and certificate CN mismatch):
- If IP works but hostname doesn’t, you have a DNS or SNI/certificate problem.
- Check latency and packet loss:
tracert api.example.com
or
mtr -rw api.example.com
- Coordinate with network team for firewall/proxy inspection (denies or slow deep packet inspection can mimic timeouts).
7) Address SSL/TLS handshakes and certificates
- Ensure your JVM supports the server’s TLS version and ciphers. Force modern protocols if necessary in jvm.config:
-Dhttps.protocols=TLSv1.2,TLSv1.3
- Verify trust chain. Import missing CA/intermediate certs into the JVM cacerts or CF’s keystore.
- Watch for SNI: Some servers require SNI; using an IP instead of hostname may fail.
- Examine errors:
- javax.net.ssl.SSLHandshakeException
- peer not authenticated
If SSL negotiation hangs,
8) Consider proxy servers and Authentication
- Confirm proxy requirements with your network team. Wrong proxy server, missing auth, or PAC file misconfigurations can cause long stalls.
- Bypass the proxy for internal or trusted domains if allowed.
Test:
curl -x http://proxy.mycorp.local:8080 -U user:pass https://api.example.com/
9) Tackle payload size and streaming
- Large downloads/uploads need longer timeouts and efficient streaming.
- For downloads: use path/file with getAsBinary=”yes” to avoid memory overhead.
- For uploads: ensure the remote server supports your method (multipart/form-data vs application/json) and chunking. Mismatched content-type can cause the remote service to wait indefinitely.
10) Control concurrency and resource limits
- Too many simultaneous
requests can: - Exhaust outbound ports (TIME_WAIT).
- Hit remote rate limits.
- Degrade throughput and increase timeouts.
- Mitigate:
- Queue or throttle calls (cfthread pools, task scheduling).
- Implement retries with exponential backoff.
- Monitor OS ephemeral ports:
- Windows: netstat -ano | find “TIME_WAIT”
- Ensure adequate server resources (CPU, RAM, network).
11) Review JVM/OS-level settings
- DNS caching (JVM):
- Consider setting networkaddress.cache.ttl to a reasonable value (e.g., 60 seconds) to avoid stale entries but reduce repeated DNS lookups.
- TCP keepalive/timeouts (OS):
- Coordinate with sysadmins; excessively short or long keepalive settings can impact long-lived HTTPs.
- Patch JVM to recent update for TLS Performance/stability improvements.
12) Add robust Error handling and logging
Use cftry/cfcatch and log meaningful context:
Include timing, URL (without secrets), and correlation IDs to expedite investigations.
Common mistakes and How to Avoid Them
- Using a short
timeout for large or slow endpoints. - Avoid by Benchmarking with curl and setting realistic timeouts.
- Forgetting the global CF request timeout is shorter than the
timeout. - Align requesttimeout with your
needs.
- Align requesttimeout with your
- Calling hostnames that require SNI using raw IPs (failing SSL).
- Always use the proper hostname for HTTPS.
- Ignoring proxies or assuming direct internet access.
- Validate proxy requirements and credentials.
- Streaming large files into memory instead of to disk.
- Use path/file and getAsBinary=”yes”.
- Over-parallelizing outbound requests leading to port exhaustion.
- Throttle concurrency and implement retries/backoff.
- Not handling or logging exceptions, making issues intermittent and opaque.
- Add structured logging and alerting.
Quick Cause / Solution Reference
- Cause: Remote API is slow or overloaded
- Solution: Increase timeout, add retries with backoff, contact provider, consider Async processing.
- Cause: DNS intermittent resolution
- Solution: Check nslookup, switch resolvers, set reasonable JVM DNS cache TTL.
- Cause: SSL/TLS handshake stalls or mismatch
- Solution: Update JVM, enable TLSv1.2+, import CA certs, ensure SNI via hostname.
- Cause: Proxy misconfiguration
- Solution: Verify proxy server/port/auth; bypass for allowed domains.
- Cause: Global CF request timeout too low
- Solution: Increase
or admin Request Timeout.
- Solution: Increase
- Cause: Large file transfers
- Solution: Stream to disk, raise timeouts, confirm content-types.
- Cause: Concurrency spikes/ephemeral port exhaustion
- Solution: Limit parallel calls, implement connection reuse, monitor OS sockets.
- Cause: Firewall/IPS delays
- Solution: Work with network team; whitelist domains; test path with traceroute/mtr.
Prevention Tips / Best practices
- Set realistic defaults:
-
appropriate to the endpoint profile (e.g., 30–120s for slow APIs). - requesttimeout ≥
.
-
- Implement retry with exponential backoff for transient failures (but never unbounded).
- Separate concerns:
- Offload long remote calls to Asynchronous tasks or queues where possible.
- Stream large content to disk and avoid unnecessary resolveURL or parsing.
- Centralize HTTP calls through a service layer that standardizes timeouts, logging, and Error handling.
- Keep JVM up-to-date; configure TLS protocols explicitly when needed.
- Monitor:
- Log ElapsedTime, StatusCode, and ErrorDetail for every call.
- Track failure rate and latency percentiles; set alerts.
- Validate proxies and firewall rules regularly; document exceptions.
- Manage DNS:
- Use reliable resolvers and monitor DNS Performance.
- Set appropriate JVM DNS caching TTLs to balance freshness and performance.
Configuration and Diagnostic Examples
Increase the ColdFusion request timeout for a long-running page
Basic GET with explicit timeout and logging
<cfhttp url=”https://api.example.com/v1/data”
method=”get”
timeout=”45″
resolveURL=”false”
throwOnError=”true”
result=”resp” />
<cflog file=”http-calls” type=”information”
text=”GET /v1/data; Status=#resp.StatusCode#; Time=#resp.ElapsedTime#ms; Error=#resp.ErrorDetail#”>
POST with large payload streamed and longer timeout
<cfhttp url=”https://api.example.com/upload”
method=”post”
timeout=”120″
multipart=”yes”
result=”resp”>
jvm.config example for TLS protocols
-Dhttps.protocols=TLSv1.2,TLSv1.3
curl diagnostics
curl -v –connect-timeout 5 -m 30 https://api.example.com/v1/data
curl -w “dns:%{time_namelookup}s connect:%{time_connect}s tls:%{time_appconnect}s starttransfer:%{time_starttransfer}s total:%{time_total}s\n” -o /dev/null -s https://api.example.com/v1/data
Key Takeaways / Summary Points
- Identify the timeout type (connect, read, SSL, proxy, or CF Request lifecycle) before changing settings.
- Align CF requesttimeout and
timeout values; ensure they’re realistic for the endpoint. - Validate network path: DNS resolution, proxies, firewalls, and SSL/TLS compatibility.
- For large transfers, stream data and raise timeouts; don’t overrun memory.
- Control concurrency and implement robust retries with backoff and structured logging.
- Keep the JVM updated and tune DNS/TLS settings as needed.
FAQ
How do I know if the timeout is during connect or during read?
- Use curl timing (-w) to see connect vs total timing. A low connect time but high total indicates a read timeout (server slow to respond). A high connect time points to connection or TLS handshake issues. Review logs for ConnectException vs SocketTimeoutException.
Can I set different connect and read timeouts for CFHTTP?
- Depending on engine/version,
may primarily control read timeout. Some engines expose separate connection timeout attributes or inherit from JVM defaults. If you need fine-grained control and your CFML engine doesn’t expose it, consider using underlying Java HTTP clients from CFML to set both timeouts explicitly.
Why does the same URL work in a browser but time out in CFHTTP?
- Browsers may use different proxies, DNS resolvers, or TLS stacks. Your server could be behind a stricter proxy/firewall, using different DNS, or missing TLS ciphers/CA certs. Test from the server with curl to replicate the CF environment.
How do I troubleshoot SSL handshake issues that look like timeouts?
- Enable TLS 1.2+ in the JVM, verify SNI (use the hostname, not a raw IP), and import the correct CA/intermediate certificates. Check for SSLHandshakeException in logs and test with:
openssl s_client -connect api.example.com:443 -servername api.example.com
What if I’m hitting rate limits and seeing timeouts intermittently?
- Check response headers or provider docs for Rate limiting. Implement retries with exponential backoff, add jitter, reduce concurrency, and consider caching or batching requests to stay within limits.
