Skip to end of metadata
Go to start of metadata

If you have high availability turned on, you will get improved reliability and performance from Sauce Connect because running multiple tunnels in a tunnel pool will balance the tests between tunnels automatically. Learn more by visiting the High availability Sauce Connect Setup page.

Tunnel pools give transparent high availability: if a tunnel in the pool becomes unavailable, another tunnel in the pool will pick up its traffic, and connectivity will be restored automatically. Each tunnel counts toward your concurrency limit, but you can manage tunnels via the Saucelabs’ tunnel management page.

Pooled tunnels generally just work and don’t require user intervention. If you run a high number of tunnels, you may want to bypass the pool and specify which tunnel to use directly.

Monitor Tunnels

If you run a high number of tunnels in your pool, you may want to monitor each tunnel to make sure you can use Sauce Labs efficiently. If a tunnel is shut down (for example, because of user shutdown, crash, maintenance, or network partition), it will be taken out of the pool of active Sauce Connect instances.

If the tunnel was stopped, it needs to be restarted: tunnel pools only contain tunnels that you have started. Sauce Labs will not start a tunnel automatically for you, since tunnels count toward your concurrency limit.

One way to make sure your tunnel configuration stays up is to monitor individual tunnels in the pool. You can monitor each tunnel by running tests on a specific tunnel.

You can get the list of tunnel identifiers via the tunnel management page, or from your Sauce Connect logs.

Once you have that list of tunnels, you can start monitoring the tunnels in the pool by running tests on each of them individually. This is a good way to ensure that tunnels are all healthy & running.

How to Implement Monitoring

To specify which tunnel in the pool you would like to use, set the value tunnelIdentifier in the desired capabilities for the test. The format looks like this: <name>::sauce::<tunnel ID>. If the tunnel pool is not named (no -i or --tunnelIdentifier was used when starting Sauce Connect), you will not be able to specify the tunnel you want to monitor in this way. We recommend using tunnel identifiers.

For example, if the name is my-production-tunnel and the tunnel ID is 0acd46dce4a711e5bbd068f72834b089, the desired capabilities would look like this:


This short Python snippet shows you how to monitor tunnels:

Monitor tunnels in pool
from selenium.webdriver import Remote
from import WebDriverWait

# This can be extracted from Sauce Connect's logs
name = 'my-production-tunnel'
tunnel_ids = ['0acd46dce4a711e5bbd068f72834b089',

for tid in tunnel_ids:
    # Specify that we need to run the test through a specific tunnel
    tunnel_identifier = '%s::sauce::%s' % (name, tid)
    desired_capabilities = {'tunnelIdentifier': tunnel_identifier}

    # Run test to ensure the tunnel works
        driver = Remote('',
        # Wait 2 minutes for the site load
        WebDriverWait(driver, 120)
    except Exception:
        print 'Error while running the test, tunnel %s may be down' % tid
  • No labels