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

Using proxy mode

Read time: 11 minutes
Last edited: Dec 13, 2024

Overview

Each SDK connects to several LaunchDarkly web services. These include services for getting feature flag data via streaming or polling, and a service for storing analytics events. By default, the SDK connects directly to LaunchDarkly for these services.

If you are using the Relay Proxy, you must configure the SDK so that it connects to the Relay Proxy for these services instead.

If you use the Relay Proxy in proxy mode, you must know the base uniform resource identifier (URI) of your Relay Proxy instance. This is an http or https address with the hostname and port where you have deployed the Relay Proxy. In all of the code examples below, the Relay Proxy's base URI is https://your-relay-proxy.com:8030, which is its default port.

Different SDKs have different ways of configuring the SDK. In some SDKs, you must set the base URI of each service to the Relay Proxy's base URI, using a separate configuration property for each service but setting each one to the same value. In other SDKs, you can set the base URI for all services with a single configuration property.

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 following examples also include configuring the events service. To learn more, read Deciding how to handle analytics events.

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 connect the SDK to the Relay Proxy, use the ServiceEndpoints builder method and Components.ServiceEndpoints().RelayProxy to specify the base URI of your Relay Proxy:

Android

Expand Android code sample

To connect the SDK to the Relay Proxy, use the streamUri, pollUri, and eventsUri builder methods to specify the base URI of your Relay Proxy:

C++ (client-side)

Expand C++ code sample

To connect the SDK to the Relay Proxy, use RelayProxyBaseURL to set the base URI of your Relay Proxy:

To learn more, read ServiceEndpoints.

Electron

Expand Electron code sample

To connect the SDK to the Relay Proxy, set the streamUrl, baseUrl, and eventsUrl options to the base URI of your Relay Proxy:

Flutter

Expand Flutter code sample

To connect the SDK to the Relay Proxy, use the ServiceEndpoints configuration option to specify the base URI of your Relay Proxy:

To learn more, read serviceEndpoints.

iOS

Expand iOS code sample

To connect the SDK to the Relay Proxy, set the streamUrl, baseUrl, and eventsUrl properties to the base URI of your Relay Proxy:

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

Expand JavaScript code sample

To connect the SDK to the Relay Proxy, set the streamUrl, baseUrl, and eventsUrl properties to the base URI of your Relay Proxy:

Node.js (client-side)

Expand Node.js (client-side) code sample

To connect the SDK to the Relay Proxy, set the streamUrl, baseUrl, and eventsUrl properties to the base URI of your Relay Proxy:

React Native

Expand React Native code sample

To connect the SDK to the Relay Proxy, set the streamUri, baseUri, and eventsUri properties to the base URI of your Relay Proxy:

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.

Roku

Expand Roku code sample
The Relay Proxy only works with the Roku SDK in polling mode

The Relay Proxy works when the Roku SDK is in polling mode only. You cannot use the Relay Proxy if the Roku SDK is in streaming mode.

To connect the SDK to the Relay Proxy, use the setStreamURI, setAppURI, and setEventsURI methods to specify the base URI of your Relay Proxy:

Server-side SDKs

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

.NET (server-side)

Expand .NET (server-side) code sample

To connect the SDK to the Relay Proxy, use the ServiceEndpoints builder method and Components.ServiceEndpoints().RelayProxy to specify the base URI of your Relay Proxy:

C++ (server-side)

Expand C++ (server-side) code sample

To connect the SDK to the Relay Proxy, use RelayProxyBaseURL to set the base URI of your Relay Proxy:

To learn more, read ServiceEndpoints() in ConfigBuilder.

Erlang

Expand Erlang code sample

To connect the SDK to the Relay Proxy, set the stream_uri, base_uri, and events_uri properties to the base URI of your Relay Proxy:

Go

Expand Go code sample

To connect the SDK to the Relay Proxy, use the Config.ServiceEndpoints property and ldcomponents.RelayProxyEndpoints() to specify the base URI of your Relay Proxy:

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

Expand Haskell code sample

To connect the SDK to the Relay Proxy, use configSetStreamURI, configSetBaseURI, and configSetEventsURI to specify the base URI of your Relay Proxy:

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

Expand Java code sample

To connect the SDK to the Relay Proxy, use the serviceEndpoints builder method and Components.serviceEndpoints().relayProxy to specify the base URI of your Relay Proxy:

Lua

Expand Lua code sample

To connect the SDK to the Relay Proxy, use the serviceEndpoints property to specify the base URLs:

To learn more about the configuration options, read clientInit.

Node.js (server-side)

Expand Node.js (server-side) code sample

To connect the SDK to the Relay Proxy, set the streamUri, baseUri, and eventsUri properties to the base URI of your Relay Proxy:

PHP

Expand PHP code sample

To connect the SDK to the Relay Proxy, set the base_uri and events_uri properties to the base URI of your Relay Proxy:

There is not a streaming service for the PHP SDK.

Python

Expand Python code sample

To connect the SDK to the Relay Proxy, set the stream_uri, base_uri, and events_uri properties to the base URI of your Relay Proxy:

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

Expand Ruby code sample

To connect the SDK to the Relay Proxy, set the service endpoints to the base URI of your Relay Proxy:

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

Expand Rust code sample

To connect the SDK to the Relay Proxy, use the ConfigBuilder and ServiceEndpointsBuilder to specify the base URI of your Relay Proxy:

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.