python simple_salesforce proxy usage

1.5k views Asked by At

I'm using python simple_salesforce module from this example: https://pypi.python.org/pypi/simple-salesforce. Specifically:

proxies = { "http": "http://10.10.1.10:3128" } from simple_salesforce import Salesforce sf = Salesforce(username='[email protected]', password='password', security_token='token', sandbox=True, proxies=proxies)

Its failing with the below error. requests.exceptions.ConnectionError: ('Connection aborted.', error(111, 'Connection refused'))

If I dont use proxy, it works fine. My requirement is to enable proxy. Any suggestions?

1

There are 1 answers

0
user3327034 On

Adding the following to the beginning of the program will solve this problem. I was using urllib2 in python and that takes care of forwarding the request through proxy. For the answer to my question:

If your hostname and port for proxy are xyz1-pqr01.abc.company.com and 3128 then import os os.environ['http_proxy'] = 'http://xyz1-pqr01.abc.company.com:3128' os.environ['https_proxy'] = 'http://xyz1-pqr01.abc.company.com:3128'