No results for ""
EXPAND ALL
  • Home
  • API docs

GIVE DOCS FEEDBACK

Service endpoint configuration

Read time: 27 minutes
Last edited: May 02, 2024

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 using the Relay Proxy in proxy mode. To learn more, read Using proxy mode.
Newer versions of LaunchDarkly SDKs replace users with contexts

A context is a generalized way of referring to the people, services, machines, or other resources that encounter feature flags in your product. Contexts replace another data object in LaunchDarkly: "users." To learn more, read Contexts.

Creating contexts and evaluating flags based on them is supported in the latest major versions of most of our SDKs. For these SDKs, the code samples on this page include the two most recent versions.

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)

Expand .NET (client-side) code sample

To configure an alternate service endpoint for the SDK, use the ServiceEndpoints builder method to specify the base URIs:

var config = Configuration
.Builder("mobile-key-123abc", ConfigurationBuilder.AutoEnvAttributes.Enabled)
.ServiceEndpoints(Components.ServiceEndpoints()
.Streaming("https://clientstream.launchdarkly.us")
.Polling("https://clientsdk.launchdarkly.us")
.Events("https://events.launchdarkly.us"))
.Build();

Android

Expand Android code sample

To configure an alternate service endpoint for the SDK, use the streamUri, pollUri, and eventsUri builder methods to specify the base URIs:

LDConfig ldConfig = new LDConfig.Builder(AutoEnvAttributes.Enabled)
.mobileKey("mobile-key-123abc")
.streamUri(Uri.parse("https://clientstream.launchdarkly.us"))
.pollUri(Uri.parse("https://clientsdk.launchdarkly.us"))
.eventsUri(Uri.parse("https://events.launchdarkly.us"))
.build();

C++ (client-side)

Expand C++ (client-side) code sample

To configure an alternate service endpoint for the SDK, use StreamingBaseUrl, PollingBaseUrl, and EventsBaseUrl to specify the base URIs:

auto config_builder = client_side::ConfigBuilder("mobile-key-123abc");
config_builder.ServiceEndpoints()
.StreamingBaseUrl("https://clientstream.launchdarkly.us")
.PollingBaseUrl("https://app.launchdarkly.us")
.EventsBaseUrl("https://events.launchdarkly.us")
auto config = config_builder.Build();

To learn more, read ServiceEndpoints.

Electron

Expand Electron code sample

To configure an alternate service endpoint for the SDK, use the streamUrl, baseUrl, and eventsUrl options to specify the base URIs:

const options = {
streamUrl: 'https://clientstream.launchdarkly.us',
baseUrl: 'https://clientsdk.launchdarkly.us',
eventsUrl: 'https://events.launchdarkly.us'
};

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

Expand Flutter code sample

To configure an alternate service endpoint for the SDK, use the ServiceEndpoints configuration option to specify the base URIs:

final config = LDConfig(
CredentialSource.fromEnvironment,
autoEnvAttributes.enabled,
serviceEndpoints: ServiceEndpoints.custom(
streaming: 'https://clientstream.launchdarkly.us',
polling: 'https://clientsdk.launchdarkly.us',
events: 'https://events.launchdarkly.us',
)
);

To learn more, read serviceEndpoints.

iOS

Expand iOS code sample

To configure an alternate service endpoint for the SDK, use the streamUrl, baseUrl, and eventsUrl properties to specify the base URIs:

var ldConfig = LDConfig(mobileKey: "mobile-key-123abc", autoEnvAttributes: .enabled)
ldConfig.streamUrl = URL(string: "https://clientstream.launchdarkly.us")
ldConfig.baseUrl = URL(string: "https://clientsdk.launchdarkly.us")
ldConfig.eventsUrl = URL(string: "https://events.launchdarkly.us")

JavaScript

Expand JavaScript code sample

To configure an alternate service endpoint for the SDK, use the streamUrl, baseUrl, and eventsUrl properties to specify the base URIs:

const options = {
streamUrl: 'https://clientstream.launchdarkly.us',
baseUrl: 'https://clientsdk.launchdarkly.us',
eventsUrl: 'https://events.launchdarkly.us'
};

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)

Expand Node.js (client-side) code sample

To configure an alternate service endpoint for the SDK, use the streamUrl, baseUrl, and eventsUrl properties to set the base URIs:

const options = {
streamUrl: 'https://clientstream.launchdarkly.us',
baseUrl: 'https://clientsdk.launchdarkly.us',
eventsUrl: 'https://events.launchdarkly.us'
};

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

Expand React Native code sample

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

import { LDOptions } from '@launchdarkly/react-native-client-sdk'
let options: LDOptions = {
streamUri: 'https://clientstream.launchdarkly.us',
baseUri: 'https://clientsdk.launchdarkly.us',
eventsUri: 'https://events.launchdarkly.us',
};

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

Expand React Web code sample

To configure an alternate service endpoint for the SDK, use the streamUrl, baseUrl, and eventsUrl options to specify the base URIs:

const options: {
baseUrl:"https://clientsdk.launchdarkly.us",
streamUrl:"https://clientstream.launchdarkly.us",
eventsUrl:"https://events.launchdarkly.us"
};

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 Configure the SDK in the React Web SDK reference.

Roku

Expand Roku code sample

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

' for a legacy Roku application
config = LaunchDarklyConfig("mobile-key-123abc")
' for a SceneGraph Roku Application
config = LaunchDarklyConfig("mobile-key-123abc", CLIENT_SCENEGRAPH_NODE)
config.setStreamURI("https://your-relay-proxy.com:8030")
config.setAppURI("https://your-relay-proxy.com:8030")
config.setEventsURI("https://your-relay-proxy.com:8030")

Server-side SDKs

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

.NET (server-side)

Expand .NET (server-side) code sample

To configure an alternate service endpoint for the SDK, use the ServiceEndpoints builder method to specify the base URIs:

var config = Configuration.Builder("sdk-key-123abc")
.ServiceEndpoints(Components.ServiceEndpoints()
.Streaming("https://stream.launchdarkly.us")
.Polling("https://sdk.launchdarkly.us")
.Events("https://events.launchdarkly.us"))
.Build();

Apex

Expand Apex code sample

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)

Expand C++ (server-side) code sample

To configure an alternate service endpoint for the SDK, use StreamingBaseUrl, PollingBaseUrl, and EventsBaseUrl to specify the base URIs:

auto config_builder = server_side::ConfigBuilder("sdk-key-123abc");
config_builder.ServiceEndpoints()
.StreamingBaseUrl("https://stream.launchdarkly.us")
.PollingBaseUrl("https://app.launchdarkly.us")
.EventsBaseUrl("https://events.launchdarkly.us")
auto config = config_builder.Build();
if (!config) {
/* an error occurred, config is not valid */
}

To learn more, read ServiceEndpoints() in ConfigBuilder.

Erlang

Expand Erlang code sample

To configure an alternate service endpoint for the SDK, use the stream_uri, base_uri, and events_uri properties to set the base URIs:

ldclient:start_instance("sdk-key-123abc", #{
stream_uri => "https://stream.launchdarkly.us",
base_uri => "https://sdk.launchdarkly.us",
events_uri => "https://events.launchdarkly.us"
})

Go

Expand Go code sample

To configure an alternate service endpoint for the SDK, use the Config.ServiceEndpoints property and interfaces.ServiceEndpoints() to specify the base URIs:

config := ld.Config{
ServiceEndpoints: interfaces.ServiceEndpoints{
Streaming: "https://stream.launchdarkly.us",
Polling: "https://sdk.launchdarkly.us",
Events: "https://events.launchdarkly.us",
},
}

Haskell

Expand Haskell code sample

To configure an alternate service endpoint for the SDK, use configSetStreamURI, configSetBaseURI, and configSetEventsURI to specify the base URIs:

{-# LANGUAGE OverloadedStrings #-}
import LaunchDarkly.Server.Config
import Data.Function ((&))
config :: Config
config = (makeConfig "sdk-key-123abc")
& configSetStreamURI "https://stream.launchdarkly.us"
& configSetBaseURI "https://sdk.launchdarkly.us"
& configSetEventsURI "https://events.launchdarkly.us"

Java

Expand Java code sample

To configure an alternate service endpoint for the SDK, use the serviceEndpoints builder method to specify the base URIs:

LDConfig config = new LDConfig.Builder()
.serviceEndpoints(Components.serviceEndpoints()
.streaming("https://stream.launchdarkly.us")
.polling("https://sdk.launchdarkly.us")
.events("https://events.launchdarkly.us"))
.build();

Lua

Expand Lua code sample

To configure an alternate service endpoint for the SDK, use the serviceEndpoints property to specify the base URLs:

local config = {
serviceEndpoints = {
streamingBaseURL = "https://stream.launchdarkly.us",
pollingBaseURL = "https://sdk.launchdarkly.us",
eventsBaseURL = "https://events.launchdarkly.us"
}
}

To learn more about the configuration options, read clientInit.

Node.js (server-side)

Expand Node.js (server-side) code sample

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

Here's an example of connecting to the federal instance:

import * as ld from '@launchdarkly/node-server-sdk';
const options ld.LDOptions = {
streamUri: 'https://stream.launchdarkly.us',
baseUri: 'https://sdk.launchdarkly.us',
eventsUri: 'https://events.launchdarkly.us',
};

Here's an example of connecting to the Relay Proxy:

import * as ld from '@launchdarkly/node-server-sdk';
const options ld.LDOptions = {
streamUri: 'https://your-relay-proxy.com:8030',
baseUri: 'https://your-relay-proxy.com:8030',
eventsUri: 'https://your-relay-proxy.com:8030',
};

PHP

Expand PHP code sample

To configure an alternate service endpoint for the SDK, use the base_uri and events_uri properties to specify the base URIs:

$client = new LaunchDarkly\LDClient("sdk-key-123abc",
[ "base_uri" => "https://sdk.launchdarkly.us",
"events_uri" => "https://events.launchdarkly.us" ]);

There is not a streaming service for the PHP SDK.

Python

Expand Python code sample

To configure an alternate service endpoint for the SDK, use the stream_uri, base_uri, and events_uri properties to specify the base URIs:

config = Config(sdk_key='sdk-key-123abc',
stream_uri="https://stream.launchdarkly.us",
base_uri="https://sdk.launchdarkly.us",
events_uri="https://events.launchdarkly.us")

Ruby

Expand Ruby code sample

To configure an alternate service endpoint for the SDK, use the stream_uri, base_uri, and events_uri properties to specify the base URIs:

config = LaunchDarkly::Config.new(
stream_uri: "https://stream.launchdarkly.us",
base_uri: "https://sdk.launchdarkly.us",
events_uri: "https://events.launchdarkly.us")

Rust

Expand Rust code sample

To configure an alternate service endpoint for the SDK, use the ConfigBuilder and ServiceEndpointsBuilder to specify the base URIs:

let config = ConfigBuilder::new("sdk-key-123abc").service_endpoints(ServiceEndpointsBuilder::new()
.streaming_base_url("https://stream.launchdarkly.us")
.polling_base_url("https://sdk.launchdarkly.us")
.events_base_url("https://events.launchdarkly.us"));