This error covers a range of issues when starting a session (specific to Java). The stack trace should provide some details on the issue. Below you will find the stack trace error for the specific issue and some suggestions on resolving it:
- Make sure you are using the correct Endpoint URL
Error in stack trace:
Caused by: java.net.UnknownHostException: <ENDPOINT URL>: nodename nor servname provided, or not known
- Use the correct port - port 80 for http and port 443 for https.
Error in Stack Trace when using http URL with port 443
Caused by: java.io.IOException: unexpected end of stream on
Caused by: java.io.EOFException: \n not found: limit=0 content=…
Error in stack trace when using https url with port 80
Caused by: javax.net.ssl.SSLException: Unsupported or unrecognized SSL message
- If you are running tests from your corporate network make sure that the firewall is allowing connection to saucelabs.com
Error in stack trace:
Caused by: java.net.ConnectException: Failed to connect to ondemand.saucelabs.com/18.104.22.168:443
Caused by: java.net.ConnectException: Connection timed out: connect
You can test this by
curl http://ondemand.saucelabs.com -v
curl https://ondemand.saucelabs.com -v
If the cURL commands fail with an error similar to below, contact your network team to make sure that our IP blocks or domain "*.saucelabs.com" is whitelisted.
Curl: Failed to connect to ondemand.saucelabs.com port 443: Timed out
You can find the IP ranges for the different data centers here.
- If you are running tests from your corporate network and need a proxy to connect to the Internet.
You can specify the proxy using System Properties, Detailed information on this can be found in this KB Article.
Another option is to specify it in the command line
java -Dhttp.proxyHost=webcache.example.com -Dhttp.proxyPort=8080
- If you have already set the proxy and still see the error, it is possible that the proxy is not allowing connections to Sauce Labs.
Are you specifying the proxy for https or http or both? And are you using the endpoint URL with the protocol for which you have set the proxy?
Make sure you can cURL via the proxy from the machine where the tests are running:
curl -v --proxy http://proxyHost:80 https://ondemand.saucelabs.com/wd/hub/status
curl -v --proxy https://user:password@proxyHost:proxyPort https://ondemand.saucelabs.com:443/wd/hub/status
If you don't have curl on the machine, open the URL https://ondemand.saucelabs.com/wd/hub/status in a browser (if the browser is using the same proxy).
- Certificate issues when using https endpoint URL.
Error in Stack Trace:
Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
You could use the http endpoint URL as a temporary workaround.
Some solutions to resolve this issue are available here.