Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testcafe failing to connect when using --proxy option #6363

Closed
ejosafat opened this issue Jul 7, 2021 · 51 comments
Closed

testcafe failing to connect when using --proxy option #6363

ejosafat opened this issue Jul 7, 2021 · 51 comments
Assignees
Labels
STATE: Need clarification An issue lacks information for further research.

Comments

@ejosafat
Copy link

ejosafat commented Jul 7, 2021

What is your Test Scenario?

I'm trying to run testcafe in our pipeline (Semaphore) using a docker image based on the official one, where the only additions are copying our tests inside it and install some other additional npm packages used by them. Those tests run against a test environment, that for security reasons can only be accessed either via VPN or a proxy. I'm using the --proxy flag but the test run fails.

From that same container, if I run curl https://mytestserver.dev --proxy $HTTP_PROXY it connects without problems, so does a Cypress container running in the same pipeline.

What is the Current behavior?

Tests fail to run, with the message

ERROR Unable to establish one or more of the specified browser connections.
1 of 1 browser connections have not been established:
- chromium:headless

Hints:
- Use the "browserInitTimeout" option to allow more time for the browser to start. The timeout is set to 2 minutes for local browsers and 6 minutes for remote browsers.
- The error can also be caused by network issues or remote device failure. Make sure that the connection is stable and the remote device can be reached.

As per suggestion here I set

DEBUG=hammerhead:*,testcafe:*

And the log is:

021-07-07T15:23:44.572Z testcafe:utils:temp-directory Found temp directories: []
2021-07-07T15:23:44.574Z testcafe:utils:temp-directory Temp directory path:  /tmp/testcafe/chrome-profile-128Nvnnsbk1AEpG
2021-07-07T15:23:44.587Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:46.423Z testcafe:compiler:typescript version: 3.9.10
2021-07-07T15:23:46.425Z testcafe:compiler:typescript options: [Object: null prototype] {
  experimentalDecorators: true,
  emitDecoratorMetadata: true,
  allowJs: true,
  pretty: true,
  inlineSourceMap: true,
  noImplicitAny: false,
  module: 1,
  moduleResolution: 2,
  target: 3,
  jsx: 2,
  suppressOutputPathCheck: true,
  skipLibCheck: true
}
2021-07-07T15:23:48.119Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.120Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.121Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.122Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.124Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.221Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.222Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.223Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.224Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.225Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.226Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.227Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.228Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.230Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.232Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.232Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.234Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.235Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.236Z testcafe:compiler:typescript path: "typescript"
2021-07-07T15:23:48.245Z testcafe:bootstrapper tests compilation took 3.67 s
2021-07-07T15:25:44.563Z testcafe:browser:connection:469Ca~Y status changed to 'closing'
2021-07-07T15:25:44.585Z testcafe:browser:connection:469Ca~Y TypeError: Cannot read property 'config' of undefined
    at BrowserProviderPluginHost.isHeadlessBrowser (/app/node_modules/testcafe/src/browser/provider/built-in/dedicated/base.js:65:51)
    at BrowserProvider.canUseDefaultWindowActions (/app/node_modules/testcafe/src/browser/provider/index.ts:260:53)
    at BrowserProvider.closeBrowser (/app/node_modules/testcafe/src/browser/provider/index.ts:323:44)
    at BrowserConnection._closeBrowser (/app/node_modules/testcafe/src/browser/connection/index.ts:208:13)
    at BrowserConnection.close (/app/node_modules/testcafe/src/browser/connection/index.ts:410:9)
    at Function._closeConnection (/app/node_modules/testcafe/src/runner/browser-set.ts:55:9)
    at async Promise.all (index 0)
    at BrowserSet.dispose (/app/node_modules/testcafe/src/runner/browser-set.ts:163:9)
    at Function.from (/app/node_modules/testcafe/src/runner/browser-set.ts:108:13)
    at async Promise.all (index 0)
2021-07-07T15:25:44.586Z testcafe:browser:connection:469Ca~Y status changed to 'closed'

I had the chance to get the logs in our proxy server, and found out this entry coming from the ip in semaphore where the container is running:

TCP_DENIED/403 4464 GET http://172.17.0.2:1337/browser/connect/sYNp3vU - HIER_NONE/- text/html

Denying access to that request is logical as it points to a local network address.

Incidentally I tried using firefox:headless just in case but found out that the --proxy option is completely ignored.

What is the Expected behavior?

I would expect the hammerhead proxy to issue requests to our proxy with the urls that our tests are visiting, not a local ip address.

Your Environment details:

  • testcafe version: 1.14.2
  • node.js version: 14.16.1
  • command-line arguments: docker run --rm -v ~/results:/app/results --env HTTP_PROXY=$HTTP_PROXY $ECR_REPO:$TESTCAFE_IMAGE chromium:headless --proxy $HTTP_PROXY
  • platform and version: Linux Ubuntu 18.04.1 VM in Semaphore
  • other:
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jul 7, 2021
@ejosafat
Copy link
Author

ejosafat commented Jul 7, 2021

I even tried to use the option --proxy-bypass with that initial request to a local IP address, but didn't work either.

@s0leris
Copy link

s0leris commented Jul 8, 2021

Got the same issue from my end - had to downgrade to testcafe: 1.14.0 until this is fixed.

@sly4you
Copy link

sly4you commented Jul 8, 2021

I can confirm since version 1.14.1 (O.S independent):

Cli options:
--proxy and --proxy-bypass are ignored

Config file options (.testcaferc.json):
proxy
proxyBypass

in both cases proxy setup variables are ignored.

@ejosafat
Copy link
Author

ejosafat commented Jul 8, 2021

@s0leris Interestingly, I downgraded and it worked for me just in Firefox, keeps failing in chromium.

@sly4you
Copy link

sly4you commented Jul 8, 2021

@ejosafat: on my hands I can confirm that v. 1.14.0 is working well on:

  • Firefox (Linux, Mac)
  • Chrome (Linux, Mac)
  • Chromium (Linux, Mac)
  • Safari (Mac)

@ejosafat
Copy link
Author

ejosafat commented Jul 8, 2021

@ejosafat: on my hands I can confirm that v. 1.14.0 is working well on:

  • Chromium (Linux, Mac)

it's that installed in your host? I'm using Chromium from the official docker image (1.14.0), maybe there is some problem with the chromium version installed there.

@miherlosev
Copy link
Collaborator

Hi folks,
Need to make sure that the --proxy and --proxy-bypass parameters are passed correctly. To check it, do the following:

  • open the node_modules/testcafe/lib/lib/runner/index.js file
  • find the run method
  • add the console.dir statement in the following way:
...
this.configuration.mergeOptions(options);
console.dir(this.configuration);
...

After that, please run your tests and share the console output.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jul 12, 2021
@sly4you
Copy link

sly4you commented Jul 12, 2021

@miherlosev, this is the output:

TestCafeConfiguration { _options: { browsers: Option { name: 'browsers', value: [Array], source: 'Input' }, src: Option { name: 'src', value: [Array], source: 'Input' }, screenshots: Option { name: 'screenshots', value: [Object], source: 'Input' }, skipJsErrors: Option { name: 'skipJsErrors', value: true, source: 'Input' }, debug: Option { name: 'debug', value: true, source: 'Configuration' }, concurrency: Option { name: 'concurrency', value: 1, source: 'Configuration' }, selectorTimeOut: Option { name: 'selectorTimeOut', value: 60000, source: 'Configuration' }, assertionTimeOut: Option { name: 'assertionTimeOut', value: 5000, source: 'Configuration' }, pageLoadTimeOut: Option { name: 'pageLoadTimeOut', value: 5000, source: 'Configuration' }, pageRequestTimeout: Option { name: 'pageRequestTimeout', value: 5000, source: 'Configuration' }, proxy: Option { name: 'proxy', value: 'xxxxxxxxxxxxxxxxxxxxxxxxxx, source: 'Input' }, 'proxy-bypass': Option { name: 'proxy-bypass', value: '127.0.0.1', source: 'Configuration' }, reporter: Option { name: 'reporter', value: [Array], source: 'Configuration' }, skipUncaughtErrors: Option { name: 'skipUncaughtErrors', value: false, source: 'Configuration' }, developmentMode: Option { name: 'developmentMode', value: true, source: 'Configuration' }, retryTestPages: Option { name: 'retryTestPages', value: false, source: 'Configuration' }, cache: Option { name: 'cache', value: false, source: 'Configuration' }, filter: Option { name: 'filter', value: null, source: 'Configuration' }, hostname: Option { name: 'hostname', value: '192.168.0.17', source: 'Input' }, port1: Option { name: 'port1', value: 61114, source: 'Input' }, port2: Option { name: 'port2', value: 61115, source: 'Input' }, ssl: Option { name: 'ssl', value: undefined, source: 'Input' }, experimentalCompilerService: Option { name: 'experimentalCompilerService', value: undefined, source: 'Input' }, configFile: Option { name: 'configFile', value: undefined, source: 'Input' }, proxyBypass: Option { name: 'proxyBypass', value: '127.0.0.1', source: 'Input' }, tsConfigPath: Option { name: 'tsConfigPath', value: undefined, source: 'Input' }, videoPath: Option { name: 'videoPath', value: undefined, source: 'Input' }, videoOptions: Option { name: 'videoOptions', value: undefined, source: 'Input' }, videoEncodingOptions: Option { name: 'videoEncodingOptions', value: undefined, source: 'Input' }, appCommand: Option { name: 'appCommand', value: undefined, source: 'Input' }, appInitDelay: Option { name: 'appInitDelay', value: 1000, source: 'Configuration' }, clientScripts: Option { name: 'clientScripts', value: undefined, source: 'Input' }, compilerOptions: Option { name: 'compilerOptions', value: [Object], source: 'Input' }, quarantineMode: Option { name: 'quarantineMode', value: undefined, source: 'Input' }, debugMode: Option { name: 'debugMode', value: false, source: 'Input' }, debugOnFail: Option { name: 'debugOnFail', value: false, source: 'Input' }, selectorTimeout: Option { name: 'selectorTimeout', value: 10000, source: 'Configuration' }, assertionTimeout: Option { name: 'assertionTimeout', value: 3000, source: 'Configuration' }, pageLoadTimeout: Option { name: 'pageLoadTimeout', value: 3000, source: 'Configuration' }, browserInitTimeout: Option { name: 'browserInitTimeout', value: undefined, source: 'Input' }, speed: Option { name: 'speed', value: 1, source: 'Configuration' }, stopOnFirstFail: Option { name: 'stopOnFirstFail', value: false, source: 'Input' }, disablePageCaching: Option { name: 'disablePageCaching', value: false, source: 'Input' }, disablePageReloads: Option { name: 'disablePageReloads', value: false, source: 'Input' }, disableScreenshots: Option { name: 'disableScreenshots', value: false, source: 'Input' }, disableMultipleWindows: Option { name: 'disableMultipleWindows', value: false, source: 'Input' }, ajaxRequestTimeout: Option { name: 'ajaxRequestTimeout', value: undefined, source: 'Input' }, takeScreenshotsOnFails: Option { name: 'takeScreenshotsOnFails', value: false, source: 'Configuration' } }, _filePath: '/Users/enrico/Documents/OdinServices/BitBucket/e2e-automation/.testcaferc.json', _overriddenOptions: [] }

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jul 12, 2021
@ejosafat
Copy link
Author

So I tested using the latest version, 1.15.0, within the latest testcafe docker image. Firefox seems to be working now, even without the --proxy-bypass option; however, chromium still fails to run (with --proxy and --proxy-bypass options in the command line). The configuration output in that last case is:

TestCafeConfiguration {
  _options: {
    src: Option { name: 'src', value: [Array], source: 'Configuration' },
    videoPath: Option {
      name: 'videoPath',
      value: 'results/videos',
      source: 'Configuration'
    },
    videoOptions: Option {
      name: 'videoOptions',
      value: [Object],
      source: 'Configuration'
    },
    screenshots: Option {
      name: 'screenshots',
      value: [Object],
      source: 'Configuration'
    },
    selectorTimeout: Option {
      name: 'selectorTimeout',
      value: 5000,
      source: 'Configuration'
    },
    reporter: Option {
      name: 'reporter',
      value: [Array],
      source: 'Configuration'
    },
    developmentMode: Option {
      name: 'developmentMode',
      value: false,
      source: 'Configuration'
    },
    retryTestPages: Option {
      name: 'retryTestPages',
      value: false,
      source: 'Configuration'
    },
    cache: Option { name: 'cache', value: false, source: 'Configuration' },
    filter: Option { name: 'filter', value: null, source: 'Configuration' },
    hostname: Option { name: 'hostname', value: '172.17.0.2', source: 'Input' },
    port1: Option { name: 'port1', value: 35075, source: 'Input' },
    port2: Option { name: 'port2', value: 42109, source: 'Input' },
    ssl: Option { name: 'ssl', value: undefined, source: 'Input' },
    experimentalCompilerService: Option {
      name: 'experimentalCompilerService',
      value: undefined,
      source: 'Input'
    },
    configFile: Option { name: 'configFile', value: undefined, source: 'Input' },
    skipJsErrors: Option { name: 'skipJsErrors', value: undefined, source: 'Input' },
    skipUncaughtErrors: Option {
      name: 'skipUncaughtErrors',
      value: undefined,
      source: 'Input'
    },
    quarantineMode: Option {
      name: 'quarantineMode',
      value: undefined,
      source: 'Input'
    },
    debugMode: Option { name: 'debugMode', value: undefined, source: 'Input' },
    debugOnFail: Option { name: 'debugOnFail', value: undefined, source: 'Input' },
    assertionTimeout: Option {
      name: 'assertionTimeout',
      value: undefined,
      source: 'Input'
    },
    pageLoadTimeout: Option {
      name: 'pageLoadTimeout',
      value: undefined,
      source: 'Input'
    },
    browserInitTimeout: Option {
      name: 'browserInitTimeout',
      value: undefined,
      source: 'Input'
    },
    speed: Option { name: 'speed', value: undefined, source: 'Input' },
    stopOnFirstFail: Option {
      name: 'stopOnFirstFail',
      value: undefined,
      source: 'Input'
    },
    disablePageCaching: Option {
      name: 'disablePageCaching',
      value: undefined,
      source: 'Input'
    },
    disablePageReloads: Option {
      name: 'disablePageReloads',
      value: undefined,
      source: 'Input'
    },
    disableScreenshots: Option {
      name: 'disableScreenshots',
      value: undefined,
      source: 'Input'
    },
    disableMultipleWindows: Option {
      name: 'disableMultipleWindows',
      value: undefined,
      source: 'Input'
    },
    pageRequestTimeout: Option {
      name: 'pageRequestTimeout',
      value: undefined,
      source: 'Input'
    },
    ajaxRequestTimeout: Option {
      name: 'ajaxRequestTimeout',
      value: undefined,
      source: 'Input'
    }
  },
  _filePath: '/app/.testcaferc.json',
  _overriddenOptions: []
}

@miherlosev
Copy link
Collaborator

Folks,

We've tested the proxy, proxy-bypass settings with a real proxy server (see our test here).
If you have issues with these settings, this means you specify them incorrectly or there is incompatibility with the proxy server in use.

Please update to the latest TestCafe version (.1.15.0) and make sure you pass proxy settings correctly (see #6363 (comment)). If the configuration output doesn't contain the proxy, proxy-bypass fields, you configured them incorrectly. Refer to the documentation to resolve the issue.
If you are using Docker, CI, or some non-local environment, please refer to its documentation to configure proxy settings correctly.
If you are sure that the issue relates to TestCafe and you can share an example that we can run locally, please feel free to create a separate issue.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jul 14, 2021
@ejosafat
Copy link
Author

I used the same command line to run 1.15.0, just replacing the browser used, in Firefox worked, in Chromium not, I would say that if the flags or the proxy server configuration were wrong, it wouldn't have worked in Firefox. Unfortunately, for security reasons, I can't share an example that runs against our proxy.

However, I do appreciate you looking into this matter and the quick response. Thanks so much!

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jul 14, 2021
@sly4you
Copy link

sly4you commented Jul 14, 2021

@miherlosev: first of all, thank you so much for your support.

I tried to use v 1.15.0 following your instructions this morning, but unfortunately it doesn't work on my environment, where with 1.14.0 running perfectly.

My question is where I can find the parser of variables, because it looks weird that just changing my package.json file replacing testcafe version from 1.14.0 to 1.14.1 (until version 1.15.0) I got different behaviour.

I would like analize differences between versions on a proxy variable parser.

Another interesting point is that between 1.14.0 and 1.14.1 (until version 1.15.0) looks that even variables about proxy, and proxyBypass on .testcaferc.json file are ignored.

@sly4you
Copy link

sly4you commented Jul 14, 2021

So I tested using the latest version, 1.15.0, within the latest testcafe docker image. Firefox seems to be working now, even without the --proxy-bypass option; however, chromium still fails to run (with --proxy and --proxy-bypass options in the command line). The configuration output in that last case is:

TestCafeConfiguration {
  _options: {
    src: Option { name: 'src', value: [Array], source: 'Configuration' },
    videoPath: Option {
      name: 'videoPath',
      value: 'results/videos',
      source: 'Configuration'
    },
    videoOptions: Option {
      name: 'videoOptions',
      value: [Object],
      source: 'Configuration'
    },
    screenshots: Option {
      name: 'screenshots',
      value: [Object],
      source: 'Configuration'
    },
    selectorTimeout: Option {
      name: 'selectorTimeout',
      value: 5000,
      source: 'Configuration'
    },
    reporter: Option {
      name: 'reporter',
      value: [Array],
      source: 'Configuration'
    },
    developmentMode: Option {
      name: 'developmentMode',
      value: false,
      source: 'Configuration'
    },
    retryTestPages: Option {
      name: 'retryTestPages',
      value: false,
      source: 'Configuration'
    },
    cache: Option { name: 'cache', value: false, source: 'Configuration' },
    filter: Option { name: 'filter', value: null, source: 'Configuration' },
    hostname: Option { name: 'hostname', value: '172.17.0.2', source: 'Input' },
    port1: Option { name: 'port1', value: 35075, source: 'Input' },
    port2: Option { name: 'port2', value: 42109, source: 'Input' },
    ssl: Option { name: 'ssl', value: undefined, source: 'Input' },
    experimentalCompilerService: Option {
      name: 'experimentalCompilerService',
      value: undefined,
      source: 'Input'
    },
    configFile: Option { name: 'configFile', value: undefined, source: 'Input' },
    skipJsErrors: Option { name: 'skipJsErrors', value: undefined, source: 'Input' },
    skipUncaughtErrors: Option {
      name: 'skipUncaughtErrors',
      value: undefined,
      source: 'Input'
    },
    quarantineMode: Option {
      name: 'quarantineMode',
      value: undefined,
      source: 'Input'
    },
    debugMode: Option { name: 'debugMode', value: undefined, source: 'Input' },
    debugOnFail: Option { name: 'debugOnFail', value: undefined, source: 'Input' },
    assertionTimeout: Option {
      name: 'assertionTimeout',
      value: undefined,
      source: 'Input'
    },
    pageLoadTimeout: Option {
      name: 'pageLoadTimeout',
      value: undefined,
      source: 'Input'
    },
    browserInitTimeout: Option {
      name: 'browserInitTimeout',
      value: undefined,
      source: 'Input'
    },
    speed: Option { name: 'speed', value: undefined, source: 'Input' },
    stopOnFirstFail: Option {
      name: 'stopOnFirstFail',
      value: undefined,
      source: 'Input'
    },
    disablePageCaching: Option {
      name: 'disablePageCaching',
      value: undefined,
      source: 'Input'
    },
    disablePageReloads: Option {
      name: 'disablePageReloads',
      value: undefined,
      source: 'Input'
    },
    disableScreenshots: Option {
      name: 'disableScreenshots',
      value: undefined,
      source: 'Input'
    },
    disableMultipleWindows: Option {
      name: 'disableMultipleWindows',
      value: undefined,
      source: 'Input'
    },
    pageRequestTimeout: Option {
      name: 'pageRequestTimeout',
      value: undefined,
      source: 'Input'
    },
    ajaxRequestTimeout: Option {
      name: 'ajaxRequestTimeout',
      value: undefined,
      source: 'Input'
    }
  },
  _filePath: '/app/.testcaferc.json',
  _overriddenOptions: []
}

I can't see in your output proxy, and proxy-ypass definitions.

You should have output like this in case of proxy, and proxyBypass use:

CLI case:

`
......
proxy: Option {
name: 'proxy',
value: 'xxxxx:xxxxx@xxxxxxx:3128',
source: 'Input'
},
proxyBypass: Option { name: 'proxyBypass', value: '127.0.0.1', source: 'Input' },
.....

`

Configuration case:

`
......
proxy: Option {
name: 'proxy',
value: 'xxxxx:xxxxx@xxxxxxx:3128',
source: 'Configuration'
},
proxyBypass: Option { name: 'proxyBypass', value: '127.0.0.1', source: 'Configuration' },
.....

`

@ejosafat
Copy link
Author

@sly4you, that's the interesting bit. I can't see the options there; however, I'm running this (from within the docker container):

$ testcafe chromium:headless --proxy $HTTP_PROXY --proxy-bypass 172.17.0.2

@sly4you
Copy link

sly4you commented Jul 15, 2021

@sly4you, that's the interesting bit. I can't see the options there; however, I'm running this (from within the docker container):

$ testcafe chromium:headless --proxy $HTTP_PROXY --proxy-bypass 172.17.0.2

That's the reason because of your issues.

It's so clear that from version 1.14.1 options about proxy are not working, unfortunately I don't have enough knowledge to look around the code and discover this bug.

Here @miherlosev has written that issue is solved, but output of configuration is still saying differently.

:(

@miherlosev
Copy link
Collaborator

My question is where I can find the parser of variables, because it looks weird that just changing my package.json file replacing testcafe version from 1.14.0 to 1.14.1 (until version 1.15.0) I got different behaviour.

The command-line argument parser is located in the 'node_modules/testcafe/lib/cli/argument-parser.ts' file.
You can debug the parsing process using the console.log statement.
Judging by your description, there is some issue with argument parsing. You can create a docker image with which it's possible to reproduce the issue, share it with us, and specify your environment details (operation system, version, terminal name, node version). We will investigate this.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jul 16, 2021
@sly4you
Copy link

sly4you commented Jul 16, 2021

My question is where I can find the parser of variables, because it looks weird that just changing my package.json file replacing testcafe version from 1.14.0 to 1.14.1 (until version 1.15.0) I got different behaviour.

The command-line argument parser is located in the 'node_modules/testcafe/lib/cli/argument-parser.ts' file.
You can debug the parsing process using the console.log statement.
Judging by your description, there is some issue with argument parsing. You can create a docker image with which it's possible to reproduce the issue, share it with us, and specify your environment details (operation system, version, terminal name, node version). We will investigate this.

I think I found the problem, and it's related not during a variables parsing, but during variable merge on file
'node_modules/testcafe/lib/runner/index.js' on function -->> useProxy() <--

Version 1.14.0 (lines 374,377)
useProxy(proxy, proxyBypass) { this.configuration.mergeOptions({ proxy, proxyBypass }); return this; }

Version 1.15.0 (lines 436,440)
useProxy(proxy, proxyBypass) { this._options.proxy = proxy; this._options.proxyBypass = proxyBypass; return this; }

It looks like that there is no merge on configuration options on last version (1.15.0), and result is that final configuration is without proxy/proxyBypass options.

I don't have lot of time to analyse what's the meaning about " this._options.proxy = proxy;", and "this._options.proxyBypass = proxyBypass;", so as a test I have simply modified version 1.15.0 function on this way:

useProxy(proxy, proxyBypass) { this._options.proxy = proxy; this._options.proxyBypass = proxyBypass; this.configuration.mergeOptions({ proxy, proxyBypass }); return this; }

And everything is back to work well, using proxy on .testcafe.json file, and even using proxy definition by cli.

I hope it will be useful for you.

Cheers :)

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jul 16, 2021
@miherlosev
Copy link
Collaborator

Thank you for the provided information. I've reproduced the problem.

For team:
The proxy settings specified in the command-line interface will not be applied to the runner.

testcafe chrome --proxy proxy-host --proxy-bypass 172.17.0.2

@miherlosev miherlosev reopened this Jul 19, 2021
@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jul 19, 2021
@VasilyStrelyaev VasilyStrelyaev removed the STATE: Need clarification An issue lacks information for further research. label Sep 6, 2021
@cyanbutton
Copy link

Hey @VasilyStrelyaev thanks for the follow up.
I can't find a site to show me my ip address that is http:// any suggestions?
How do I test https:// sites through a proxy like in version 1.14.0? Tried establishing an https connection with the TestCafe server from the example here, but my ip address does not change.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Sep 7, 2021
@VasilyStrelyaev
Copy link
Collaborator

http://ipinfo.io/ip does open through HTTP, but Cloudflare wouldn't allow me to connect via the public proxies I managed to find. Can you please try to use HTTP and disable HTTP/2 in your project simultaneously? To disable HTTP/2, use the disableHttp2 configuration file property or pass the disableHttp2 option to the runner.run() method. I just want to check if the problem persists and we still need to find a way to reproduce it.

The limitation due to which TestCafe cannot access HTTPS websites via external proxies is intended and has been in effect since before 1.14.0. I cannot determine the cause of the behavior you see in 1.14.0 without additional investigation.

To sum up, you cannot use external proxies for HTTPS and HTTP/2 connections with the current TestCafe version.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Sep 8, 2021
@mhanci92
Copy link

mhanci92 commented Sep 8, 2021

Hi @miherlosev
I've been looking for an open proxy that would work with TestCafe, had no luck, but using version 1.14.0 and running
testcafe chrome test.js --proxy 147.135.225.62:8139 would return Failed to connect to the proxy. error. When using 1.15.3 the test would just run, but ignore the proxy, the IP address does not change. Have attached an example that checks the IP to see if it's the same as the proxy. You'll need to run npm install, it will install 1.15.3. Hope this helps.

I'm experiencing the same issue that @cyanbutton described with testcafe version 1.15.3. Testcafe seems to just ignore the proxy settings. I use the CLI, not the testcafe runner. When downgrading to testcafe version 1.14.0, the issue is not reproducable anymore. The issues seems to start occuring with version 1.14.1. Hence, I deduce from there that the changes that came with 1.14.1 cause the wrong behavior that we observe. To make sure that version 1.14.0 does not ignore the proxy, I tried the following case successfully:
nonexisting-proxy-fails-as-expected
When running the same exact setup with Testcafe Version 1.14.1 or above, the expected error when establishing a connection to the proxy server does not occur anymore.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Sep 8, 2021
@cyanbutton
Copy link

cyanbutton commented Sep 8, 2021

Sadly http://ipinfo.io/ip converts to https:// before the page loads, and I can't find a site to show me my IP that uses http://.

Do we know why TestCafe limited external proxies to only http:// pages?

@cyanbutton
Copy link

cyanbutton commented Sep 8, 2021

Just found http://test-ipv4.com/ that works with http:// using this, TestCafe 1.15.3 and a proxy, shows the proxy address for me. So it looks like the proxy work correctly for http:// sites. Is there a plan to allow external proxies to have access to https:// pages?

@ejosafat
Copy link
Author

ejosafat commented Sep 9, 2021

This is interesting. Our testing server is https, and 1.14.0 works fine. Our proxy server only gets request to the test URL. However, any version above that, our proxy server register this in the logs:

TCP_DENIED/403 4464 GET http://172.17.0.2:1337/browser/connect/sYNp3vU - HIER_NONE/- text/html

where that IP is the internal IP of the docker container where the tests are running, which means is sending a request to the proxy with the IP address of the container; as it's a local network address, the proxy denies the request.

@samlin86
Copy link

samlin86 commented Sep 9, 2021

+1 same issue that @cyanbutton @mhanci92 are experiencing. After 1.14.0 I'm unable to connect to https sites via proxy.

@aleks-pro
Copy link
Contributor

@samlin86 , @mhanci92, @cyanbutton did you try to use disableHttp2:

{
"disableHttp2": true
}

Anyway, the fact that you need to enable this option to test the https page over the proxy looks like a bug. We will investigate it and update this thread once we have any results.

@aleks-pro aleks-pro reopened this Sep 15, 2021
@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Sep 15, 2021
@aleks-pro aleks-pro added the TYPE: bug The described behavior is considered as wrong (bug). label Sep 15, 2021
@cyanbutton
Copy link

@aleks-pro Just tried "disableHttp2": true workaround and am able to connect to https sites via proxy using 1.16.0. 😮 🥳
Not sure how I missed this in @VasilyStrelyaev comment 😓
THANK YOU BOTH!

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Sep 15, 2021
@aleks-pro aleks-pro removed the STATE: Need response An issue that requires a response or attention from the team. label Sep 17, 2021
@miherlosev miherlosev self-assigned this Dec 15, 2021
@miherlosev
Copy link
Collaborator

miherlosev commented Dec 15, 2021

Hi folks,

We automatically downgrade the protocol to HTTP 1 if proxy settings are enabled. So, using the disableHttp2 option is not necessary.
Try removing this option and run your tests with the latest testcafe version (1.17.2-rc.2) and let us know about the results.

@miherlosev miherlosev added STATE: Need clarification An issue lacks information for further research. and removed TYPE: bug The described behavior is considered as wrong (bug). FREQUENCY: level 1 labels Dec 15, 2021
@no-response no-response bot closed this as completed Dec 15, 2021
@miherlosev miherlosev reopened this Dec 15, 2021
@DevExpress DevExpress deleted a comment from no-response bot Dec 15, 2021
@no-response
Copy link

no-response bot commented Dec 15, 2021

This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.

@no-response no-response bot closed this as completed Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATE: Need clarification An issue lacks information for further research.
Projects
None yet
Development

No branches or pull requests