Affected: Server-side SDKs
Symptoms
The server-side SDKs fail to connect using streaming mode using the stream.launchdarkly.com endpoint, but the sdk.launchdarkly.com endpoint for polling mode is available.
Cause
If the server-side streaming endpoints are temporarily non-functional, SDKs that use streaming cannot receive real-time updates from LaunchDarkly, and new or restarting services will not be able to load the initial feature flag payload from LaunchDarkly.
Solution
There are two workarounds:
Option 1: Use polling mode
Configure your SDKs to poll for updates instead of streaming them.
Below are a few examples for some of our server-side SDKs. The examples all use the default minimum polling interval of 3600 seconds (5 minutes); you may adjust this to be higher if you are not making frequent flag, segment, and/or metric changes in the affected LaunchDarkly environments.
.NET version 8.x:
var config = Configuration.Builder(sdkKey)
.DataSource(Components.PollingDataSource()
.PollInterval(TimeSpan.FromSeconds(3600)))
.Build();Java version 7.x:
LDConfig config = new LDConfig.Builder()
.dataSource(Components.pollingDataSource().pollInterval(Duration.ofSeconds(45)))
.build();
Node version 9.x
const client = init('sdk-key', {
stream: false, // turn off streaming to use polling
pollInterval: 3600
});
Python version 9.x
from ldclient import LDClient, Config
client = LDClient(Config("sdk-key", stream=False, poll_interval=3600))
Option 2: Use LD Relay in offline mode
Use LD Relay in offline mode to serve flag data from a local archive instead of the LaunchDarkly streaming endpoints. Note: This option is only available for customers on Enterprise plans.
To use this option:
- Go to your Relay settings page.
- Create a Relay Proxy autoconfig token and save it.
-
Use an inline policy to limit which environments are included in the archive. For example:
[ { "actions": ["*"], "effect": "allow", "resources": ["proj/default:env/production"] } ] -
Download the archive:
curl -vv https://sdk.launchdarkly.com/relay/latest-all \ -H "Authorization: $LD_RELAY_KEY" \ -o data.tar.gz
-
Move
data.tar.gzto the host or container that runs LD Relay.You can:
- Use an init container to fetch the file from an object store like S3
- Mount it via a persistent volume
- Bake it into the image
-
Set the following environment variable in your LD Relay container:
FILE_DATA_SOURCE=/path/to/data.tar.gz
- Remove any
LD_ENV_*variables or autoconfiguration settings. Do not set up other LaunchDarkly environments in the Relay Proxy configuration file when using offline mode.