Enforce BrowserStack build requests to use port 443. #4282
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using Nightwatch with BrowserStack, the following error occurred in certain cases when trying to get builds data from BrowserStack or send the test results at the end of the test run:
Error Reproduction
As I was trying to reproduce this, when I changed the port at which we connect to the Selenium grid from 443 to 4444, the build-related requests to BrowserStack started failing for me as well, but with a different error:
On investigating this further, while still trying to reproduce the original error, I found that the above
ERR_INVALID_PROTOCOL
error was occurring because of the user-agent being set for the requests -- Nightwatch only sets the user-agent protocol ashttps
if the request is being made to the port443
, otherwise the protocol is always set tohttp
(something we should fix), and due to this mismatch (https
request being sent withhttp
user-agent), the above error was being encountered.Also, I found that the user-agent was getting set only if the
keep-alive
property was set totrue
. So, as soon as I switched thekeep-alive
property tofalse
, I was able to reproduce the original error.Fix
The root cause of the original error is that the
https://api.browserstack.com
website does not listen on any port other than443
. So, this PR enforces all the BrowserStack build-related requests to be made to the port443
instead of the port used for communicating with BrowserStack Selenium grid.