Issues with Sauce-connect proxy

Hi all,

I’ve been having a few issues lately with the Sauce connect proxy. Currently, I run my job very similar to what is suggested here: https://circleci.com/docs/2.0/browser-testing/#sauce-labs

I’ll go through the process of getting the proxy up and running (latest version, correct credentials) but once it’s up and running when I run:

wget --retry-connrefused --no-check-certificate -T 60 localhost:4445

I keep getting a connection refused. I’ve eliminated any problems with the account by running it locally, it’s only when I attempt to run it in CircleCI it fails.

Am I missing something? Has something changed of late?

Additionally. I’m using circleci/openjdk:14-buster-node-browsers and I’ve noticed when SSH’ed in a quick check of the java version returns version 11 rather than 14. Not sure that has anything to do with the problem but it’s driving me a bit nuts.

I’m not sure exactly how you are implementing your tests, but from looking at the documentation you linked, you’ll probably need to add an additional step to wait for port 4445 to open.

I’m adding an updated version below, but that documentation should probably get updated as well.

A few notes.

I’ve changed the kill -9 to kill -15. kill -9 will actually cause that step to fail with an exit 137 error as opposed to a “Build was canceled” message. In reality, you can even leave that step out and CircleCI will send SIGTERM (kill -15) at the end of the job for any background steps.

I removed the wget --retry-connrefused --no-check-certificate -T 60 localhost:4445 line as that is within the background: true step. This means this will not actually pause the next step. Instead, I added an additional step that makes use of netcat(nc) and waits for the port to open. You do not want to have that in the same step as setting up the network resource.

version: 2.1

jobs:
  build:
    docker:
      - image: circleci/python:buster-node-browsers
    steps:
      - checkout
      - run: pip install -r requirements.txt
      - run:
          name: Install Sauce Labs and Set Up Tunnel
          background: true
          command: |
            curl https://saucelabs.com/downloads/sc-4.4.12-linux.tar.gz -o saucelabs.tar.gz
            tar -xzf saucelabs.tar.gz
            cd sc-*
            bin/sc -u ${SAUCELABS_USER} -k ${SAUCELABS_KEY}
      - run:
          name: Wait for port
          command: |
            while ! nc -z localhost 4445; do
              sleep 1
            done
      - run: # base image is python, so we run `nosetests`, an extension of `unittest`
          command: nosetests
      - run:
          name: Shut Down Sauce Connect Tunnel
          command: |
            kill -15 `cat /tmp/sc_client.pid`

workflows:
  wf:
    jobs:
      - build

Hopefully, that helps and we’ll get those docs updated so that others won’t run into the same issues you did.

Hi @mike

Thanks for the suggestion, however, I tried updating my config with the port wait solution and the build just sits waiting for the port to be open. I’ve scaled back my config.yml to just isolate the issue and have dropped in the details here:

`run_assets_tests:

docker:
  - image: circleci/openjdk:14-buster-node-browsers

steps:
  - restore_cache:
      key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
  - run:
      name: Install Sauce Labs and Set Up Tunnel
      background: true
      command: |
        curl https://saucelabs.com/downloads/sc-4.6.2-linux.tar.gz -o saucelabs.tar.gz
        tar -xzf saucelabs.tar.gz
        cd sc-*
        bin/sc -u ${SAUCE_USERNAME} -k ${SAUCE_ACCESS_KEY} -x https://eu-central-1.saucelabs.com/rest/v1
  - run:
      name: Wait for port
      command: |
        while ! nc -z localhost 4445; do
          sleep 1
        done
  - run:
      name: Startup local proxy
      background: true
      command: |
        npm install
        npm start
      working_directory: .utilities/rbp-proxy/local/
  - run:
      command: |
          echo "[BUILDING] Assets"
          npm install
          npm test
          npm run build
          cd ..
          cd api
          if [[ -z "${APPLITOOLS_API_KEY}" ]]; then
            printf "Skipping visual checks because no applitools api key has been set. Assign a key to APPLITOOLS_API_KEY to run visual checks"
            mvn install -Drevision=$(git rev-parse --short HEAD) -Dvisual.skip.test=true
          else
            mvn install -Drevision=$(git rev-parse --short HEAD)
          fi
      working_directory: assets/js
      environment:
        BROWSER: remote
  - save_cache:
      paths:
        - assets/
      key: v1-dependencies-{{ .Environment.CIRCLE_SHA1 }}-assets`