Communicate reliably between GCP and on-prem ¶

This guide shows you how to configure HTTP clients to handle firewall timeouts when calling on-premises services from GCP.

Prerequisites ¶

  • Application running in GCP
  • Calling services in on-prem FSS environment via *.fss-pub.nais.io ingress
  • Access to modify HTTP client configuration

Background ¶

The on-prem firewall drops idle connections after 60 minutes without sending TCP close signals. HTTP clients reusing these dead connections will fail with timeout or connection reset errors.

Steps ¶

1. Configure HTTP client connection time-to-live ¶

Set connection TTL to 55 minutes (below the 60-minute firewall timeout):

java
java
java
kotlin
javascript
javascript
javascript

2. Enable TCP keep-alive ¶

Enable SO_KEEPALIVE to send periodic packets on idle connections (shown in Spring WebClient example above).

3. Configure background eviction ¶

Set background eviction to proactively remove stale connections every 5 minutes (shown in Spring WebClient example above).

4. Monitor metrics and logs ¶

Use OpenTelemetry auto-instrumentation to track error rates and latency:

promql
promql

Monitor application logs for these errors (should decrease after configuration):

  • java.net.SocketTimeoutException: Connection timed out
  • java.net.SocketException: Connection reset by peer
  • Connection closed prematurely BEFORE response