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`

Bit of a zombie thread bump, but I’m still struggling with this. Any recommendations?

Hi @mwinteringham! Are you using the Sauce Labs orb by any chance?

Hi @thekatertot

I’m not, the most current config is what is shown above. I’ll try having a play with the Sauce Labs orb and see how I get on. But it’d be good to get a sense of whether the issue is with the Image I’m using or if I’m doing something else wrong.

So I took a look at the Orb and tbh I don’t understand them and need to spend some more time working out how they would fit into my workflow.

Fortunately, the Orb source isn’t too full on so I copied that into my workflow. There isn’t that much difference between my workflow and what was in the Orb but sadly even with the tweaks it’s still failing.

Basically I get this error every time I attempt to load up localhost (after a successful wget so Sauce Labs is up and running).

It’s driving me mad, because I can’t tell if the issue is Sauce or the workflow.

canvas

Spamming my own thread here a little, but I resolved the issue. CircleCI was working perfectly fine (How I could I ever doubted you :stuck_out_tongue:)

Turns out that the URLs for Sauce labs have changed slightly so I was opening a tunnel to one datacenter but attempting to access a legacy one. Once I updated them both to use the correct data center, it all fell into place.

1 Like

I’m glad it’s resolved!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.