Just a second...

Connecting through a load balancer

Connections between Diffusion™ clients and Diffusion servers can be routed through a load balancer. Some clients can pass additional information to a load balancer in the request path of their URL.

Supported in: JavaScript® , Apple® , Android™ , C and Java™ APIs

An additional request path can be specified to define the connection URL context.

JavaScript
try {
    const session = await diffusion.connect({
        host : 'host_name',
        port : 'port',
        transports : 'transport',
        secure : false,
        path: 'path/diffusion'
    });

    // At this point we now have a connected session.
    console.log('Connected');
} catch(error) {
    console.error('Failed to create session!', error);
}
Java and Android
final Session session = Diffusion
    .sessions()
    .serverHost("localhost")
    .serverPort(8080)
    .transports(Transport.HTTP_POLLING)
    .secureTransport(false)
    .requestPath("/path/diffusion")
    .open();
Apple
let host = "host"
let additional_information_as_path = "path"

// Formulate the URL string for connection via secure WebSocket,
// appending the required 'diffusion` suffix
let url_string = String(format: "wss://%@/%@/diffusion", host, additional_information_as_path)

// Open the session, using the formulated URL.
// Use the configuration to open a new session...
PTDiffusionSession.open(with: URL(string: url_string)!) { (session, error) in

    // Check error is `nil`, then use session as required.
    // Ensure to maintain a strong reference to the session beyond the lifetime
    // of this callback, for example by assigning it to an instance variable.

    if (session == nil) {
        print("Failed to open session: %@", error!.localizedDescription)
        return
    }

    // At this point we now have a connected session.
    print("Connected.")
}

Specify a request path that begins with / and ends with /diffusion. The default value is /diffusion.

Load balancer configuration

Connections between Diffusion clients and Diffusion servers have specific requirements. If your load balancer handles Diffusion connections incorrectly, for example by routing subsequent client requests to different backend Diffusion servers, this can cause problems for your solution.

For more information about how to configure your load balancers to work with Diffusion , see Load balancers.