Cluster Configuration

A “cluster” represents the physical location of the servers that handle requests from your Channels app. For example, the Channels cluster mt1 is in Northern Virginia in the United States. When you create a Channels app, you can choose which cluster it exists in. You might choose this to achieve lower latency or to comply with data protection regulations.

What clusters exist?

Channels has the following public clusters:

  • mt1 in N. Virginia
  • us2 in Ohio
  • eu in Ireland
  • ap1 in Singapore
  • ap2 in Mumbai

If you require other locations, we can create dedicated Channels clusters in custom locations on request: talk to us.

How should I choose a cluster?

  • To achieve lower network latency.
    • Depending on your use case, having your Channels app hosted close to its customers or your servers may help improve the latency when sending and receiving messages.
    • We recommend that you test on multiple clusters and pick the one that works best for your app.
  • To comply with data protection regulations.
    • European data protection regulations specify that personal user data should not leave the EU borders.
    • For this use-case, Channels offers a cluster in eu-west-1, an AWS datacenter located in Ireland.

How do you configure the cluster option?

Where it says APP_CLUSTER you’ll need to insert the relevant cluster shortcode (e.g. mt1).

On the client-side:

var pusher = new Pusher("APP_KEY", {
  cluster: "APP_CLUSTER"
});
let options = PusherClientOptions(
    host: .cluster("eu")
)

let pusher = Pusher(key: "YOUR_APP_KEY", options: options)
pusher.connect()
OCAuthMethod *authMethod = [[OCAuthMethod alloc] initWithAuthEndpoint:@"https://your.authendpoint/pusher/auth"];
OCPusherHost *host = [[OCPusherHost alloc] initWithCluster:@"eu"];
PusherClientOptions *options = [[PusherClientOptions alloc]
                                initWithOcAuthMethod:authMethod
                                attemptToReturnJSONObject:YES
                                autoReconnect:YES
                                ocHost:host
                                port:nil
                                encrypted:YES];

Pusher *pusher = [[Pusher alloc] initWithAppKey:@"YOUR_APP_KEY" options:options];
[pusher connect];
#import <Pusher/Pusher.h>

self.client = [PTPusher pusherWithKey:@"APP_KEY" delegate:self cluster:@"APP_CLUSTER"];

[self.client connect];
import com.pusher.client.Pusher;

PusherOptions options = new PusherOptions();
options.setCluster("APP_CLUSTER");

Pusher pusher = new Pusher("APP_KEY", options);

pusher.connect();

On the server-side:

require 'pusher'

pusher_client = Pusher::Client.new(
  app_id: 'APP_ID',
  key: 'APP_KEY',
  secret: 'APP_SECRET',
  cluster: 'APP_CLUSTER'
);
require __DIR__ . '/vendor/autoload.php';

$pusher = new Pusher\Pusher(APP_KEY, APP_SECRET, APP_ID, array(
  'cluster' => 'APP_CLUSTER'
));
var Pusher = require('pusher');

var pusher = new Pusher({
  appId: 'APP_ID',
  key: 'APP_KEY',
  secret: 'APP_SECRET',
  cluster: 'APP_CLUSTER'
});
using PusherServer;
using System.Web.Mvc;
using System.Net;
using Your.Config;

public class HelloWorldController : Controller {
  [httpPost]
  public ActionResult HelloWorld() {
    var options = new PusherOptions();
    options.Cluster = Config.AppCluster;
    var pusher = new Pusher(Config.AppId, Config.AppKey, Config.AppSecret, options);
  }
}
from pusher import Pusher

pusher = Pusher(
  app_id=u'APP_ID',
  key=u'APP_KEY',
  secret=u'APP_SECRET',
  cluster=u'APP_CLUSTER'
)
package main

import "github.com/pusher/pusher-http-go"

func main(){
  client := pusher.Client{
    AppId: "APP_ID",
    Key: "APP_KEY",
    Secret: "APP_SECRET",
    Cluster: "APP_CLUSTER",
  }
}
Pusher pusher = new Pusher("APP_ID", "APP_KEY", "APP_SECRET");

pusher.setCluster("APP_CLUSTER");

Details

  • Setting the cluster option will change the host parameter of the Channels library you are using. This happens only when the host option is not set, in which case, cluster is ignored.
  • For client libraries, the default host is ws.pusherapp.com (and sockjs.pusherapp.com for fallback transports). With cluster set, the host becomes ws-cluster.pusher.com (and sockjs-cluster.pusher.com respectively).
  • For server libraries, the default host is api.pusherapp.com. With cluster set, the host becomes api-cluster.pusher.com.

How to debug it?

  • First make sure your app is created in the intended cluster and that all the Channels libraries you are using in your project are configured correctly.
  • Make sure your app makes requests to the correct endpoints. On the server-side, use a traffic sniffing tool like tcpdump. On the client-side, open your browser’s developer tools and inspect the network requests.
  • Contact support

Have you tried using the search to find what you’re after? If you still have a question then get in touch with us and let us help you out.