Skip to content

Commit

Permalink
Honor HTTP proxy settings on connection probing
Browse files Browse the repository at this point in the history
Previously, when Rally probed for an Internet connection, it just opened
a plain socket connection. This is problematic when a user connects via
a proxy to the Internet because Rally will then conclude that there is
no working Internet connection at all.

With this commit, we respect the HTTP proxy setting on connection
probing too.

Closes #245
  • Loading branch information
danielmitterdorfer committed Mar 2, 2017
1 parent ca7d06d commit 4291fd3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions esrally/utils/net.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import os
import shutil
import socket

import certifi
import urllib3
Expand Down Expand Up @@ -57,10 +56,16 @@ def retrieve_content_as_string(url):

def has_internet_connection():
try:
# We connect to Github anyway later on so we use that to avoid touching too much different remote endpoints
socket.create_connection(("www.github.com", 80))
return True
except OSError:
# We connect to Github anyway later on so we use that to avoid touching too much different remote endpoints.
probing_url = "https://github.com/"
logger.debug("Checking for internet connection against [%s]" % probing_url)
# We do a HTTP request here to respect the HTTP proxy setting. If we'd open a plain socket connection we circumvent the
# proxy and erroneously conclude we don't have an Internet connection.
response = __http().request("GET", probing_url)
status = response.status
logger.debug("Probing result is HTTP status [%s]" % str(status))
return status == 200
except BaseException:
return False


Expand Down

0 comments on commit 4291fd3

Please sign in to comment.