With the IP proxy feature, OpenTok clients route all internet traffic (except for media streams) via your proxy server.
Non-media traffic includes communication to the Video API servers and logging infrastructure.
The IP proxy feature is available as an add-on feature.
There is also a configurable TURN server add-on feature that lets you route media streams via your own custom TURN servers.
You set the URL or your proxy server when you initiate an OpenTok session in the OpenTok client SDKs.
OpenTok concatenates the destination URL for all internet traffic (except media streams) to the proxy URL you provide. This traffic includes Video API calls, WebSocket connections, and log traffic made by OpenTok.js.
For example, the OpenTok client SDK logs data periodically to
https://hlg.tokbox.com/prod/logging/ClientEvent
. If you set the proxy URL
to "https://123.123.123.123:8080"
, the client will post
this data to
https://123.123.123.123:8080/hlg.tokbox.com/prod/logging/ClientEvent
.
You should secure the proxy server so that it will be used by OpenTok clients only and not by unauthorized clients. For example, you can put the proxy server within a firewall or authenticate requests in some other way.
Here is sample code that sets up a basic proxy server for this feature: https://github.com/opentok/simple_reverse_proxy.
Note: If clients will connect to OpenTok sessions in a geographical region other than that of your proxy server and you are not using the configurable TURN server feature, be sure to set the location hint when you create OpenTok sessions.
Call the OT.setProxyUrl()
method to set the proxy server URL:
OT.setProxyUrl('https://123.123.123.123:8080');
You must call this method before calling any other OpenTok methods. This ensures that the proxy server is used for OpenTok traffic.
Note: This method was added as an undocumented method in OpenTok 2.17.4.
In previous versions, you set the proxy server URL using an undocumented option
when calling the OT.initSession()
method. However, this is option now deprecated
and replaced with the OT.setProxyUrl()
method.
Set the proxy server URL by calling the setProxyUrl()
method of the
Session.Builder
object you use to instantiate a Session object:
mSession = new Session.Builder(context, API_KEY, SESSION_ID)
.setProxyUrl("https://123.123.123.123:8080")
.build();
Set the proxy server URL by setting the proxyURL
property of the
OTSessionSettings
object you pass into the
[OTSession initWithApiKey:sessionId:delegate:settings:]
method:
OTSessionSettings *settings = [[OTSessionSettings alloc] init];
settings.proxyURL = @"https://123.123.123.123:8080";
session = [[OTSession alloc] initWithApiKey:kApiKey
sessionId:kSessionId
delegate:self
settings:settings];
Set the proxy server URL by setting the proxyUrl
parameter of the
Session()
constructor:
Session = new Session.Builder(Context.Instance, API_KEY, SESSION_ID)
{
ProxyUrl = "https://123.123.123.123:8080"
}.Build();
Set the proxy server URL by calling the otc_session_settings_set_proxy_url()
function:
otc_session_settings_set_proxy_url(session_settings, "https://123.123.123.123:8080");
otc_session *session = otc_session_new_with_settings(API_KEY,
SESSION_ID,
&session_callbacks,
session_settings);
The first parameter is the otc_session_settings
instance you will pass into
the otc_session_new_with_settings()
function to initialize an otc_session
instance. The second parameter is the proxy server URL.
For more information on the otc_session_settings
struct, the
otc_session_new_with_settings()
function, and connecting to the session, see
Instantiating an otc_session instance and session-related callbacks.
Set the proxy server URL by calling the otc_session_settings_set_proxy_url()
function:
otc_session_settings_set_proxy_url(session_settings, "https://123.123.123.123:8080");
otc_session *session = otc_session_new_with_settings(API_KEY,
SESSION_ID,
&session_callbacks,
session_settings);
The first parameter is the otc_session_settings
instance you will pass into
the otc_session_new_with_settings()
function to initialize an otc_session
instance. The second parameter is the proxy server URL.
For more information on the otc_session_settings
struct, the
otc_session_new_with_settings()
function, and connecting to the session, see
Instantiating an otc_session instance and session-related callbacks.
Set the proxyUrl
property of the options
prop you pass into the OTSession
component:
<OTSession
apiKey="your-api-key"
sessionId="your-session-id"
token="your-session-token"
options={{
proxyUrl: 'https://123.123.123.123:8080',
// ... other options
}}
>
<OTPublisher/>
<OTSubscriber/>
</OTSession>