Docs

  • Channels Channels
  • Beams Beams
  • Developers
  • Support
  • Blog
  • Sign up
    • Search powered by Algolia
    • Sign in
    • Sign up
    • Channels
    • Getting started
      • SDK quick starts
        • JavaScript quick start
        • iOS quick start
        • Android quick start
        • Flutter quick start
        • React Native quick start
      • Use case quick starts
        • Javascript realtime chart
        • Javascript realtime user list
      • Debugging
    • Using channels
      • Client API overview
      • Connection
      • User authentication
      • Watchlist events
      • Functions
      • Authorized connections
      • Channels
      • Public channels
      • Private channels
      • Encrypted channels
      • Presence channels
      • Cache channels
      • Events
      • Global configuration
      • Websocket fallbacks
      • Device compatibility
    • Server api
      • Overview
      • HTTP API interaction
      • Webhooks
      • Authenticating users
      • Authorizing users
      • Sending events to authenticated users
      • Terminating user connections
      • Excluding event recipients
    • Channels libraries
      • API libraries
    • Pusher cli
      • Overview
      • Installation
      • Documentation
    • Miscellaneous
      • Clusters
      • Integrations
      • Resources
    • Library auth reference
      • Authentication and authorization signatures
      • HTTP API reference
      • Pusher Channels Protocol
      • Server library reference specification
      • Logging
    • Beams
    • Pusher lab

    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
    • us3 in Oregon
    • eu in Ireland
    • ap1 in Singapore
    • ap2 in Mumbai
    • ap3 in Tokyo
    • ap4 in Sydney
    • sa1 in São Paulo

    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];

    self.pusher = [[Pusher alloc] initWithAppKey:@"YOUR_APP_KEY" options:options];
    [self.pusher connect];
    import com.pusher.client.Pusher;

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

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

    pusher.connect();
    window.Echo = new Echo({
    broadcaster: "pusher",
    key: "APP_KEY",
    cluster: "APP_CLUSTER",
    });
    using PusherClient;

    public class Program
    {
    private static Pusher pusher;

    public static void Main(string[] args)
    {
    pusher = new Pusher("APP_KEY", new PusherOptions()
    {
    Cluster = "APP_CLUSTER",
    Encrypted = true
    });
    }
    }

    ∞ On the server-side:

    require 'pusher'

    pusher = 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'
    ));
    // In config/broadcasting.php

    'options' => [
    'cluster' => 'APP_CLUSTER'
    ],
    const Pusher = require("pusher");

    const 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);
    }
    }
    import pusher

    pusher_client = 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/v5"

    func main(){
    pusherClient := 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

    Contents

    • What clusters exist?
    • How should I choose a cluster?
    • How do you configure the cluster option?
      • On the client-side:
      • On the server-side:
    • Details
    • How to debug it?

    Spotted something that isn’t quite right? Create an issue on GitHub.

    Copyright © 2024 Pusher Ltd. All rights reserved.

    • Support,
    • Status
    • Follow Pusher on Twitter Twitter
    • Subscribe to Pusher’s channel on YouTube
    • Follow Pusher on LinkedIn
    • Follow Pusher on Github GitHub
    • Follow Pusher on Twitch Twitch
    • Follow Pusher on Discord Discord