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

Network logging restricts websockets usage #106

Open
dimkin-eu opened this issue Jun 9, 2020 · 5 comments
Open

Network logging restricts websockets usage #106

dimkin-eu opened this issue Jun 9, 2020 · 5 comments

Comments

@dimkin-eu
Copy link

dimkin-eu commented Jun 9, 2020

if AUT is using ws for communication - it fails when running on Browserstack, because fails to connect
update - see the workaround in the end

Environment (please complete the following information):

  • WebdriverIO version: 6.1
  • Mode: [ WDIO Testrunner]
  • If WDIO Testrunner, running sync/async: [ sync ]
  • Node.js version: [v12.16.1]
  • NPM version: [6.14.5]
  • Browser name and version: [Chrome 83]
  • Platform name and version: [macOS Catalina 10.15.5]
  • Additional wdio packages used (if applicable):

To reproduce

  1. save files in one folder
  2. add env vars BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY
  3. run npm install and then npm test
    package.json
    bsSpec.js
    wdio.conf.js

Same happens, if BrowserstackLocal started as background service ./BrowserStackLocal --key somekey

Expected behavior
test runs

Actual behavior

using localtesing ws connect fails

1591701360194:SEVERE:https://www.websocket.org/js/echo.js 135 WebSocket connection to 'wss://echo.websocket.org/?encoding=text' failed: Error during WebSocket handshake: Unexpected response code: 400

Screenshot 2020-06-09 at 14 35 16

Workaround
As turned out - network logging "turns off" ws communication

@dimkin-eu
Copy link
Author

dimkin-eu commented Jun 9, 2020

@shawnlobo96 maybe you can help with this issue? :)

@anthony-fdes
Copy link

@dimkin-eu Can you execute the tests without Network Logs? Also, BrowserStack only supports secure Web Sockets so could you please confirm if you are using secure Web Sockets only?

@dimkin-eu
Copy link
Author

@anthony-fdes , under secure WebSockets you mean wss://? then yes - they are used
And yes, turning off network logs made ws working. This is quite nasty and not obvious :(
Can this be fixed or at least mentioned on https://www.browserstack.com/local-testing/automate ?

Thank you for fast heads-up :)

@dimkin-eu dimkin-eu changed the title BrowserstackLocal fails to connect websocket Network logging restricts websockets usage Jun 10, 2020
@shawnlobo96
Copy link

shawnlobo96 commented Jun 10, 2020

Hey @dimkin-eu,

You can try adding the below capability:

'browserstack.wsLocalSupport': 'true'

This has been documented under https://www.browserstack.com/automate/capabilities. This should allow WebSocket connections with network logs enabled. The reason for using this capability is mentioned as:

Chrome browser v71 and above have changed the way PAC files are supported. 
Use this capability to enable WSS (WebSocket Secure) connections to work with Network Logs on Chrome browser v71 and above.

If you are using localhost in your test, change it to bs-local.com

Note: This capability is only valid for Chrome browsers v71 and above.

I hope you find this useful :)

@dimkin-eu
Copy link
Author

@shawnlobo96 , nice, will check :)

This needs some more things, if one testing locally and in Browserstack, will check this too

  • If you are using localhost in your test, change it to bs-local.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants