You're happily testing along and BAM! Your tests stop being able to access your application under test. When you go to check your server, you find that the output from Sauce Connect includes something like:
18 Jan 18:09:47 - Warning: Remote tunnel VM has been terminated by user request. Shutting down.
18 Jan 18:09:47 - Waiting for the connection to terminate...
18 Jan 18:09:47 - Connection closed, exit code: 8.
Well, either you or someone else, tried to start another tunnel with the same credentials and the same tunnel identifier (Or no identifier at all). Sauce Connect only supports running one tunnel with a given identifier (including no identifier) at a time.
First, double-check why an additional tunnel started. Was it built into one of the tools you're using with Sauce? Did your CI Server start a tunnel, or a co-worker using the same credentials? I am personally guilty of starting multiple tunnels on my development machine and forgetting, then wondering why some of them fail >.>
Next, if you determine you need both tunnels at once, your next steps depend on how you want your Sauce Labs tests to access your applications under test:
I never test without Sauce Connect
I want multiple tests run simultaneously on different machines to access a default specific application under test
Start an unidentified tunnel on a machine that can contact the application under test, and leave it running. Do not provide a tunnel identifier. Do not start a tunnel as part of your tests.
To test against a different application, use a tunnel identifier as part of your tests' desired capabilities. You can either start a Sauce Connect tunnel using that identifier when you start your tests or have one running permanently on a machine able to contact the application under test.
I want multiple tests run simultaneously on different machines to access different applications under test
Provide a tunnel identifier as a desired capability in your tests. Start each Sauce Connect instance with its own tunnel identifier.
If an application under test will be accessed by more than one machine running tests, start Sauce Connect on a machine that can access the application under test, using a tunnel identifier, and leave it running. Do not start an instance of Sauce Connect as part of those tests.
I only ever run tests from one machine at once
Your tests can start a Sauce Connect tunnel themselves, or you can leave one running on another machine that can contact the application under test. Tunnel identifiers are optional.
I sometimes test without Sauce Connect
I run tests only from one machine at a time
Start an identified tunnel on a machine that can contact the application under test, either running permanently or started by your tests. Add the tunnel-identifier desired capability to your test code.
I run tests from multiple locations at once
Start an identified tunnel on a machine that can contact the application under test, and leave it running. Add the tunnel-identifier desired capability to your code. Do not start a tunnel as part of your test setup.
I want to run without Sauce Connect
Remove the tunnel-identifier desired capability from your code.
You can read the complete documentation for Sauce Connect here.
For information about Tunnel Identifiers, check here.