• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
    No results for ""
    EXPAND ALL

    EDIT ON GITHUB

    Service endpoint configuration

    Read time: 3 minutes
    Last edited: Oct 27, 2022

    Overview

    This topic explains how to configure LaunchDarkly SDKs to connect to alternate service endpoints. Typically this is only required for customers working with the LaunchDarkly federal instance.

    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.

    Each SDK is configured by default to connect these services. Most customers do not need to configure service endpoints.

    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.

    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.

    The example code uses endpoint values specific to the LaunchDarkly federal instance

    You can use the methods and options described on this page to configure any alternate service endpoints.

    The code samples all use URIs from the federal instance of LaunchDarkly, because working with a federal instance is the most common use case for setting alternate service endpoints.

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

    • Client-side SDKs
    • Server-side SDKs

    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("YOUR_MOBILE_KEY")
    .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()
    .mobileKey("YOUR_MOBILE_KEY")
    .streamUri(Uri.parse("https://clientstream.launchdarkly.us"))
    .pollUri(Uri.parse("https://clientsdk.launchdarkly.us"))
    .eventsUri(Uri.parse("https://events.launchdarkly.us"))
    .build();

    C/C++ (client-side)

    Expand C/C++ (client-side) code sample

    To configure an alternate service endpoint for the SDK, use LDConfigSetStreamURI, LDConfigSetAppURI, and LDConfigSetEventsURI to specify the base URIs:

    struct LDConfig *config = LDConfigNew("YOUR_MOBILE_KEY");
    LDConfigSetStreamURI(config, "https://clientstream.launchdarkly.us");
    LDConfigSetAppURI(config, "https://app.launchdarkly.us");
    LDConfigSetEventsURI(config, "https://events.launchdarkly.us");

    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://app.launchdarkly.us',
    eventsUrl: 'https://events.launchdarkly.us'
    };

    Flutter

    Expand Flutter 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 = LDConfigBuilder("YOUR_MOBILE_KEY")
    .streamUri("https://clientstream.launchdarkly.us")
    .pollUri("https://clientsdk.launchdarkly.us")
    .eventsUri("https://events.launchdarkly.us")
    .build();

    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: "YOUR_MOBILE_KEY")
    ldConfig.streamUrl = URL(string: "https://clientstream.launchdarkly.us")
    ldConfig.baseUrl = URL(string: "https://app.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://app.launchdarkly.us',
    eventsUrl: 'https://events.launchdarkly.us'
    };

    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://app.launchdarkly.us',
    eventsUrl: 'https://events.launchdarkly.us'
    };

    React Native

    Expand React Native code sample

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

    let config = {
    mobileKey: 'YOUR_MOBILE_KEY',
    streamUri: 'https://clientstream.launchdarkly.us',
    pollUri: 'https://app.launchdarkly.us',
    eventsUri: 'https://events.launchdarkly.us',
    };

    React Web

    Expand React 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://app.launchdarkly.us",
    streamUrl:"https://clientstream.launchdarkly.us",
    eventsUrl:"https://events.launchdarkly.us"
    };

    To learn more, read Configuring the React SDK.

    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("YOUR_SDK_KEY")
    .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 Using 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/C++ (server-side)

    Expand C/C++ (server-side) code sample

    To configure an alternate service endpoint for the SDK, use LDConfigSetStreamURI, LDConfigSetBaseURI, and LDConfigSetEventsURI to specify the base URIs:

    struct LDConfig *config = LDConfigNew("YOUR_SDK_KEY");
    LDConfigSetStreamURI(config, "https://stream.launchdarkly.us");
    LDConfigSetBaseURI(config, "https://app.launchdarkly.us");
    LDConfigSetEventsURI(config, "https://events.launchdarkly.us");

    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("YOUR_SDK_KEY", #{
      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 "YOUR_SDK_KEY")
    & configSetStreamURI "https://stream.launchdarkly.us"
    & configSetBaseURI "https://app.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://app.launchdarkly.us")
    .events("https://events.launchdarkly.us"))
    .build();

    Lua

    Expand Lua code sample

    To configure an alternate service endpoint for the SDK, use the streamURI, baseURI, and eventsURI properties to specify the base URIs:

    local config = {
    key = YOUR_SDK_KEY,
    streamURI = "https://stream.launchdarkly.us",
    baseUri = "https://app.launchdarkly.us",
    eventsURI = "https://events.launchdarkly.us",
    }

    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:

    const options = {
    streamUri: 'https://stream.launchdarkly.us',
    baseUri: 'https://app.launchdarkly.us',
    eventsUri: 'https://events.launchdarkly.us',
    };

    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("YOUR_SDK_KEY",
    [ "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='YOUR_SDK_KEY',
    stream_uri="https://stream.launchdarkly.us",
    base_uri="https://app.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").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"));