Service endpoint configuration

Overview

This topic explains how to configure LaunchDarkly SDKs to connect to alternate service endpoints.

Each SDK connects to several LaunchDarkly web services. These include services for getting feature flag data using streaming or polling, and a service for storing analytics events. Optionally, you can configure LaunchDarkly to connect to alternate service endpoints.

Most customers do not need to configure service endpoints. You may need to configure service endpoints in the following situations:

  • You are working with the LaunchDarkly federal instance. If you are using the federal instance of LaunchDarkly, you must configure the SDK so that it connects to the federal instance for these services instead.
  • You are working with the LaunchDarkly European Union (EU) instance. If you are using the EU instance of LaunchDarkly, you must configure the SDK so that it connects to the federal instance for these services instead. To learn which URLs to use instead, read the EU instance documentation.
  • You are using the Relay Proxy in proxy mode. To learn more, read Using proxy mode.
  • You are using the LaunchDarkly CLI to run a local dev-server for testing, and you want to access local flag values from there. To learn more, read Using the LaunchDarkly CLI for local testing.

The examples below show how to configure the SDK for each service. In most SDKs, you then need to pass the configuration in as a parameter when you initialize the client. To learn more, read Configuration.

Details about each SDK’s configuration are available in the SDK-specific sections below:

Client-side SDKs

This feature is available in the following client-side SDKs:

.NET (client-side)

To configure an alternate service endpoint for the SDK, use the ServiceEndpoints builder method to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1var config = Configuration
2 .Builder("mobile-key-123abc", ConfigurationBuilder.AutoEnvAttributes.Enabled)
3 .ServiceEndpoints(Components.ServiceEndpoints()
4 .RelayProxy("https://your-relay-proxy.com:8030"))
5 .Build();

Android

To configure an alternate service endpoint for the SDK, use the streamUri, pollUri, and eventsUri builder methods to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1LDConfig ldConfig = new LDConfig.Builder(AutoEnvAttributes.Enabled)
2 .mobileKey("mobile-key-123abc")
3 .serviceEndpoints(
4 Components.serviceEndpoints()
5 .relayProxy("https://your-relay-proxy.com:8030")
6 )
7 .build();

C++ (client-side)

To configure an alternate service endpoint for the SDK, use StreamingBaseUrl, PollingBaseUrl, and EventsBaseUrl to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1auto config_builder = client_side::ConfigBuilder("mobile-key-123abc");
2config_builder.ServiceEndpoints()
3 .StreamingBaseUrl("https://your-relay-proxy.com:8030")
4 .PollingBaseUrl("https://your-relay-proxy.com:8030")
5 .EventsBaseUrl("https://your-relay-proxy.com:8030")
6auto config = config_builder.Build();

To learn more, read ServiceEndpoints.

Electron

To configure an alternate service endpoint for the SDK, use the streamUrl, baseUrl, and eventsUrl options to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1const options = {
2 streamUrl: 'https://your-relay-proxy.com:8030',
3 baseUrl: 'https://your-relay-proxy.com:8030',
4 eventsUrl: 'https://your-relay-proxy.com:8030'
5};

The Electron SDK uses the baseUrl for the initial connection and subsequent identify calls.

If you have enabled streaming, the SDK uses the streamUrl for subsequent connections. If you have enabled useReport, these subsequent requests will use the REPORT HTTP request method. These REPORT requests are streaming requests only if you have installed the LaunchDarkly EventSource polyfill to provide streaming support. Otherwise, these requests will be standard REPORT http requests. To learn more, read EventSource under Requirements and polyfills.

Flutter

To configure an alternate service endpoint for the SDK, use the ServiceEndpoints configuration option to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1final config = LDConfig(
2 CredentialSource.fromEnvironment,
3 autoEnvAttributes.enabled,
4 serviceEndpoints: ServiceEndpoints.relayProxy('https://your-relay-proxy.com:8030')
5);

To learn more, read serviceEndpoints.

iOS

To configure an alternate service endpoint for the SDK, use the streamUrl, baseUrl, and eventsUrl properties to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1var ldConfig = LDConfig(mobileKey: "mobile-key-123abc", autoEnvAttributes: .enabled)
2ldConfig.streamUrl = URL(string: "https://your-relay-proxy.com:8030")
3ldConfig.baseUrl = URL(string: "https://your-relay-proxy.com:8030")
4ldConfig.eventsUrl = URL(string: "https://your-relay-proxy.com:8030")
Relay Proxy compatibility with event payload compression

If you are using LaunchDarkly iOS SDK version 9.9 or greater and you choose to enable compression of event payloads, you must upgrade Relay Proxy to version 8.9 or greater. To learn more, read enableCompression and Configuring an SDK to use the Relay Proxy.

JavaScript

To configure an alternate service endpoint for the SDK, use the streamUrl, baseUrl, and eventsUrl properties to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1const options = {
2 streamUrl: 'https://your-relay-proxy.com:8030',
3 baseUrl: 'https://your-relay-proxy.com:8030',
4 eventsUrl: 'https://your-relay-proxy.com:8030'
5};

The JavaScript SDK uses the baseUrl for the initial connection and subsequent identify calls.

If you have enabled streaming, the SDK uses the streamUrl for subsequent connections. If you have enabled useReport, these subsequent requests will use the REPORT HTTP request method. These REPORT requests are streaming requests only if you have installed the LaunchDarkly EventSource polyfill to provide streaming support. Otherwise, these requests will be standard REPORT http requests. To learn more, read EventSource under Requirements and polyfills.

Node.js (client-side)

To configure an alternate service endpoint for the SDK, use the streamUrl, baseUrl, and eventsUrl properties to set the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1const options = {
2 streamUrl: 'https://your-relay-proxy.com:8030',
3 baseUrl: 'https://your-relay-proxy.com:8030',
4 eventsUrl: 'https://your-relay-proxy.com:8030'
5};

The Node.js (client-side) SDK uses the baseUrl for the initial connection and subsequent identify calls.

If you have enabled streaming, the SDK uses the streamUrl for subsequent connections. If you have enabled useReport, these subsequent requests will use the REPORT HTTP request method. These REPORT requests are streaming requests only if you have installed the LaunchDarkly EventSource polyfill to provide streaming support. Otherwise, these requests will be standard REPORT http requests. To learn more, read EventSource under Requirements and polyfills.

React Native

To configure an alternate service endpoint for the SDK, use the streamUri, baseUri, and eventsUri properties to set the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1import { LDOptions } from '@launchdarkly/react-native-client-sdk'
2
3let options: LDOptions = {
4 streamUri: 'https://your-relay-proxy.com:8030',
5 baseUri: 'https://your-relay-proxy.com:8030',
6 eventsUri: 'https://your-relay-proxy.com:8030',
7};

In version 6.x and earlier, the config properties were named streamUri, pollUri, and eventsUri. They were renamed to streamUrl, pollUrl, and eventsUrl in version 7.0. In version 10.0, they are named streamUri, baseUri, and eventsUri. To learn more, read LDOptions.

React Web

To configure an alternate service endpoint for the SDK, use the streamUrl, baseUrl, and eventsUrl options to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1const options = {
2 baseUrl: 'https://your-relay-proxy.com:8030',
3 streamUrl: 'https://your-relay-proxy.com:8030',
4 eventsUrl: 'https://your-relay-proxy.com:8030'
5};

The React Web SDK uses the baseUrl for the initial connection and subsequent identify calls.

If you have enabled streaming, the SDK uses the streamUrl for subsequent connections. If you have enabled useReport, these subsequent requests will use the REPORT HTTP request method. These REPORT requests are streaming requests only if you have installed the LaunchDarkly EventSource polyfill to provide streaming support. Otherwise, these requests will be standard REPORT http requests. To learn more, read EventSource under Requirements and polyfills.

To learn more, read Configuration options in the React Web SDK reference.

Roku

To configure an alternate service endpoint for the SDK, use the setStreamURI, setAppURI, and setEventsURI methods to specify the base URIs:

BrightScript, connecting to Relay Proxy
1' for a legacy Roku application
2config = LaunchDarklyConfig("mobile-key-123abc")
3
4' for a SceneGraph Roku Application
5config = LaunchDarklyConfig("mobile-key-123abc", CLIENT_SCENEGRAPH_NODE)
6
7config.setStreamURI("https://your-relay-proxy.com:8030")
8config.setAppURI("https://your-relay-proxy.com:8030")
9config.setEventsURI("https://your-relay-proxy.com:8030")

Server-side SDKs

This feature is available for the following server-side SDKs:

.NET (server-side)

To configure an alternate service endpoint for the SDK, use the ServiceEndpoints builder method to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1var config = Configuration.Builder("sdk-key-123abc")
2 .ServiceEndpoints(Components.ServiceEndpoints()
3 .RelayProxy("https://your-relay-proxy.com:8030"))
4 .Build();

Apex

First, set up the Apex bridge. If you are a federal customer, make sure you run the Apex bridge within your own FedRAMP-compliant environment. To learn more, read Use the LaunchDarkly Salesforce bridge.

To configure an alternate service endpoint for the SDK, export the alternate URIs before you build the bridge:

$cd bridge && go build .
>
># other required export statements...
>
>export LD_BASE_URI='https://sdk.launchdarkly.us'
>export LD_EVENTS_URL='https://events.launchdarkly.us'
>
>./bridge

C++ (server-side)

To configure an alternate service endpoint for the SDK, use StreamingBaseUrl, PollingBaseUrl, and EventsBaseUrl to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1auto config_builder = server_side::ConfigBuilder("sdk-key-123abc");
2config_builder.ServiceEndpoints()
3 .RelayProxyBaseUrl("https://your-relay-proxy.com:8030");
4auto config = config_builder.Build();
5if (!config) {
6 /* an error occurred, config is not valid */
7}

To learn more, read ServiceEndpoints() in ConfigBuilder.

Erlang

To configure an alternate service endpoint for the SDK, use the stream_uri, base_uri, and events_uri properties to set the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1ldclient:start_instance("sdk-key-123abc", #{
2 stream_uri => "https://your-relay-proxy.com:8030",
3 base_uri => "https://your-relay-proxy.com:8030",
4 events_uri => "https://your-relay-proxy.com:8030"
5})

Go

To configure an alternate service endpoint for the SDK, use the Config.ServiceEndpoints property and interfaces.ServiceEndpoints() to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1// To use the Replay Proxy in proxy mode for both streaming and events:
2
3config := ld.Config{
4 ServiceEndpoints: ldcomponents.RelayProxyEndpoints(
5 "https://your-relay-proxy.com:8030"),
6}
7
8// Alternatively, to use the Relay Proxy in proxy mode for streaming,
9// but send events directly to LaunchDarkly, use:
10config := ld.Config{
11 ServiceEndpoints: ldcomponents.RelayProxyEndpointsWithoutEvents(
12 "https://your-relay-proxy.com:8030"),
13}
Relay Proxy compatibility with event payload compression

If you are using LaunchDarkly Go SDK version 7.6 or greater and you choose to enable compression of event payloads, you must upgrade Relay Proxy to version 8.9 or greater. To learn more, read EnableGzip and Configuring an SDK to use the Relay Proxy.

Haskell

To configure an alternate service endpoint for the SDK, use configSetStreamURI, configSetBaseURI, and configSetEventsURI to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1{-# LANGUAGE OverloadedStrings #-}
2
3import LaunchDarkly.Server.Config
4
5import Data.Function ((&))
6
7config :: Config
8config = (makeConfig "sdk-key-123abc")
9 & configSetStreamURI "https://your-relay-proxy.com:8030"
10 & configSetBaseURI "https://your-relay-proxy.com:8030"
11 & configSetEventsURI "https://your-relay-proxy.com:8030"
Relay Proxy compatibility with event payload compression

If you are using LaunchDarkly Haskell SDK version 4.4 or greater and you choose to enable compression of event payloads, you must upgrade Relay Proxy to version 8.9 or greater. To learn more, read configSetCompressEvents and Configuring an SDK to use the Relay Proxy.

Java

To configure an alternate service endpoint for the SDK, use the serviceEndpoints builder method to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1LDConfig config = new LDConfig.Builder()
2 .serviceEndpoints(Components.serviceEndpoints()
3 .relayProxy("https://your-relay-proxy.com:8030"))
4 .build();

Lua

To configure an alternate service endpoint for the SDK, use the serviceEndpoints property to specify the base URLs. Here are some examples for common base URLs that you might use instead of the defaults:

1local config = {
2 serviceEndpoints = {
3 streamingBaseURL = "https://your-relay-proxy.com:8030",
4 pollingBaseURL = "https://your-relay-proxy.com:8030",
5 eventsBaseURL = "https://your-relay-proxy.com:8030"
6 }
7}

To learn more about the configuration options, read clientInit.

Node.js (server-side)

To configure an alternate service endpoint for the SDK, use the streamUri, baseUri, and eventsUri properties to specify the base URIs.

Here are some examples for common base URIs that you might use instead of the defaults:

1import { LDOptions } from '@launchdarkly/node-server-sdk';
2
3const options: LDOptions = {
4 streamUri: 'https://your-relay-proxy.com:8030',
5 baseUri: 'https://your-relay-proxy.com:8030',
6 eventsUri: 'https://your-relay-proxy.com:8030',
7};

PHP

To configure an alternate service endpoint for the SDK, use the base_uri and events_uri properties to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1$client = new LaunchDarkly\LDClient("sdk-key-123abc",
2 [ "base_uri" => "https://your-relay-proxy.com:8030",
3 "events_uri" => "https://your-relay-proxy.com:8030" ]);

There is not a streaming service for the PHP SDK.

Python

To configure an alternate service endpoint for the SDK, use the stream_uri, base_uri, and events_uri properties to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1config = Config(sdk_key='sdk-key-123abc',
2 stream_uri="https://your-relay-proxy.com:8030",
3 base_uri="https://your-relay-proxy.com:8030",
4 events_uri="https://your-relay-proxy.com:8030")
Relay Proxy compatibility with event payload compression

If you are using LaunchDarkly Python SDK version 9.5 or greater and you choose to enable compression of event payloads, you must upgrade Relay Proxy to version 8.9 or greater. To learn more, set enable_event_compression in the ldclient.config module and read Configuring an SDK to use the Relay Proxy.

Ruby

To configure an alternate service endpoint for the SDK, use the stream_uri, base_uri, and events_uri properties to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1config = LaunchDarkly::Config.new(
2 stream_uri: "https://your-relay-proxy.com:8030",
3 base_uri: "https://your-relay-proxy.com:8030",
4 events_uri: "https://your-relay-proxy.com:8030")
Relay Proxy compatibility with event payload compression

If you are using LaunchDarkly Ruby SDK version 8.7 or greater and you choose to enable compression of event payloads, you must upgrade Relay Proxy to version 8.9 or greater. To learn more, read compress_events and Configuring an SDK to use the Relay Proxy.

Rust

To configure an alternate service endpoint for the SDK, use the ConfigBuilder and ServiceEndpointsBuilder to specify the base URIs. Here are some examples for common base URIs that you might use instead of the defaults:

1let config = ConfigBuilder::new("sdk-key-123abc")
2 .service_endpoints(
3 ServiceEndpointsBuilder::new().relay_proxy("https://your-relay-proxy.com:8030"),
4 )
5 .build();
Relay Proxy compatibility with event payload compression

If you are using LaunchDarkly Rust SDK version 2.4 or greater and you choose to enable compression of event payloads, you must upgrade Relay Proxy to version 8.9 or greater. To learn more, read compress_events and Configuring an SDK to use the Relay Proxy.

Built with