---
title: Proxy Your Mobile RUM Data
description: >-
  Set up proxy configuration for mobile RUM data collection with multiple SDK
  options and protocol support for network routing.
breadcrumbs: >-
  Docs > RUM & Session Replay > Real User Monitoring & Session Replay Guides >
  Proxy Your Mobile RUM Data
---

# Proxy Your Mobile RUM Data

## Overview{% #overview %}

The RUM Mobile SDKs can be configured to send requests through a proxy.

{% section displayed-if="SDK is Android" %}
This section only applies to users who meet the following criteria: SDK is Android

Proxies use [OkHttpClient Proxy and Authenticator](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html) on Android.
{% /section %}

{% section displayed-if="SDK is iOS" %}
This section only applies to users who meet the following criteria: SDK is iOS

Proxies use [URLSessionConfiguration.connectionProxyDictionary](https://developer.apple.com/documentation/foundation/urlsessionconfiguration/1411499-connectionproxydictionary) on iOS.
{% /section %}

## Prerequisite proxy setup{% #prerequisite-proxy-setup %}

{% section displayed-if="Protocol is HTTP/HTTPS" %}
This section only applies to users who meet the following criteria: Protocol is HTTP/HTTPS

To successfully forward a request to Datadog, your proxy must support [HTTP CONNECT](https://www.rfc-editor.org/rfc/rfc9110#CONNECT) requests.
{% /section %}

{% section displayed-if="Protocol is SOCKS" %}
This section only applies to users who meet the following criteria: Protocol is SOCKS

To successfully forward a request to Datadog, your proxy must support [SOCKS5 proxying](https://datatracker.ietf.org/doc/html/rfc1928).
{% /section %}

## Recommended SDK setup{% #recommended-sdk-setup %}

{% section displayed-if="Protocol is HTTP/HTTPS" %}
This section only applies to users who meet the following criteria: Protocol is HTTP/HTTPS

{% section displayed-if="SDK is Android" %}
This section only applies to users who meet the following criteria: SDK is Android

When initializing the Android SDK, specify the following proxy configuration:

```
val configBuilder = Configuration.Builder(
    clientToken = "<client token>",
    env = "<environment>"
)

val proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress("<www.example.com>", <123>))
val authenticator = ProxyAuthenticator("<proxy user>", "<proxy password>")

configBuilder.setProxy(proxy, authenticator)
```

For more information, see the [OkHttpClient Proxy and Authenticator](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html) documentation.
{% /section %}

{% section displayed-if="SDK is iOS" %}
This section only applies to users who meet the following criteria: SDK is iOS

When initializing the iOS SDK, specify the following proxy configuration:

{% tab title="Swift" %}

```
import DatadogCore

Datadog.initialize(
  with: Datadog.Configuration(
    clientToken: "<client token>",
    env: "<environment>",
    proxyConfiguration: [
        kCFNetworkProxiesHTTPEnable: true,
        kCFNetworkProxiesHTTPPort: <123>,
        kCFNetworkProxiesHTTPProxy: "<www.example.com>",
        kCFProxyUsernameKey: "<proxy user>",
        kCFProxyPasswordKey: "<proxy password>"
    ]
  ),
  trackingConsent: trackingConsent
)
```

{% /tab %}

{% tab title="Objective C" %}

```
@import DatadogObjc;

DDConfiguration *configuration = [[DDConfiguration alloc] initWithClientToken:@"<client token>" env:@"<environment>"];
configuration.proxyConfiguration = @{
    (NSString *)kCFNetworkProxiesHTTPEnable: @YES,
    (NSString *)kCFNetworkProxiesHTTPPort: @<123>,
    (NSString *)kCFNetworkProxiesHTTPProxy: @"<www.example.com>",
    (NSString *)kCFProxyUsernameKey: @"<proxyuser>",
    (NSString *)kCFProxyPasswordKey: @"<proxypass>"
};

[DDDatadog initializeWithConfiguration:configuration
                       trackingConsent:trackingConsent];
```

For more information, see the [URLSessionConfiguration.connectionProxyDictionary](https://developer.apple.com/documentation/foundation/urlsessionconfiguration/1411499-connectionproxydictionary) documentation.
{% /tab %}
{% /section %}

{% section displayed-if="SDK is React Native" %}
This section only applies to users who meet the following criteria: SDK is React Native

When initializing the React Native SDK, specify the following proxy configuration:

```
import { DatadogProviderConfiguration, ProxyConfiguration, ProxyType } from '@datadog/mobile-react-native';

const config = new DatadogProviderConfiguration('<client token>', '<environment>', '<application id>');

config.proxyConfig = new ProxyConfiguration(ProxyType.HTTPS, '<www.example.com>', <123>, '<proxy user>', '<proxy password>');
```
{% /section %}
{% /section %}

{% section displayed-if="Protocol is SOCKS" %}
This section only applies to users who meet the following criteria: Protocol is SOCKS

{% section displayed-if="SDK is Android" %}
This section only applies to users who meet the following criteria: SDK is Android

When initializing the Android SDK, specify the following proxy configuration:

```
val configBuilder = Configuration.Builder(
    clientToken = "<client token>",
    env = "<environment>"
)

val proxy = Proxy(Proxy.Type.SOCKS, InetSocketAddress("<www.example.com>", <123>))
val authenticator = ProxyAuthenticator("<proxy user>", "<proxy password>")

configBuilder.setProxy(proxy, authenticator)
```

For more information, see the [OkHttpClient Proxy and Authenticator](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html) documentation.
{% /section %}

{% section displayed-if="SDK is iOS" %}
This section only applies to users who meet the following criteria: SDK is iOS

When initializing the iOS SDK, specify the following proxy configuration:

{% tab title="Swift" %}

```
import DatadogCore

Datadog.initialize(
  with: Datadog.Configuration(
    clientToken: "<client token>",
    env: "<environment>",
    proxyConfiguration: [
        kCFNetworkProxiesSOCKSEnable: true,
        kCFNetworkProxiesSOCKSPort: <123>,
        kCFNetworkProxiesSOCKSProxy: "<www.example.com>",
        kCFProxyUsernameKey: "<proxy user>",
        kCFProxyPasswordKey: "<proxy password>"
    ]
  ),
  trackingConsent: trackingConsent
)
```

{% /tab %}

{% tab title="Objective C" %}

```
@import DatadogObjc;

DDConfiguration *configuration = [[DDConfiguration alloc] initWithClientToken:@"<client token>" env:@"<environment>"];
configuration.proxyConfiguration = @{
    (NSString *)kCFNetworkProxiesSOCKSEnable: @YES,
    (NSString *)kCFNetworkProxiesSOCKSPort: @<123>,
    (NSString *)kCFNetworkProxiesSOCKSProxy: @"<www.example.com>",
    (NSString *)kCFProxyUsernameKey: @"<proxyuser>",
    (NSString *)kCFProxyPasswordKey: @"<proxypass>"
};

[DDDatadog initializeWithConfiguration:configuration
                       trackingConsent:trackingConsent];
```

For more information, see the [URLSessionConfiguration.connectionProxyDictionary](https://developer.apple.com/documentation/foundation/urlsessionconfiguration/1411499-connectionproxydictionary) documentation.
{% /tab %}
{% /section %}

{% section displayed-if="SDK is React Native" %}
This section only applies to users who meet the following criteria: SDK is React Native

When initializing the React Native SDK, specify the following proxy configuration:

```
import { DatadogProviderConfiguration, ProxyConfiguration, ProxyType } from '@datadog/mobile-react-native';

const config = new DatadogProviderConfiguration('<client token>', '<environment>', '<application id>');

config.proxyConfig = new ProxyConfiguration(ProxyType.SOCKS, '<www.example.com>', <123>, '<proxy user>', '<proxy password>');
```
{% /section %}
{% /section %}

## Further reading{% #further-reading %}

- [Learn about Real User Monitoring](https://docs.datadoghq.com/real_user_monitoring/)
