3

I'm using requests and zeep library to connect to a server using SOAP API. If I manually set the internet proxy, I can connect. However, I intend to use proxy setting in my script to automate the process. I'm using the following block of code to do that, but I'm getting the error below. Can anyone pls help me where am I making the mistake?

ConnectionError: HTTPSConnectionPool(host='xxxl.com', port=443): Max retries exceeded with url: /webservice.php?wsdl (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))

from requests import Session
from requests.auth import HTTPBasicAuth  
from zeep import Client
from zeep.transports import Transport

session = Session()
session.proxies = {'http': 'http://abcdef.com:80'}
session.auth = HTTPBasicAuth('username', 'passwd')
client = Client('https://abcxyz.com/webservice.php?wsdl',
    transport=Transport(session=session))
bastelflp
  • 9,362
  • 7
  • 32
  • 67
Toufiq
  • 61
  • 1
  • 9

1 Answers1

0

Use your proxy authentication to handle the proxy with requests, not the session auth. Set the proxies with user:pass:

proxies = {
    "http": "user:pass@your_proxy:port",
    "https": "user:pass@your_proxy:port",
}
bastelflp
  • 9,362
  • 7
  • 32
  • 67
  • Hi @bastelflp, unfortunately it didn't work for me. Still gives the same error. I replaced session.proxies = {'http': 'http://abcdef.com:80'} with session.proxies = = { "http": "user:pass@your_proxy:port", "https": "user:pass@your_proxy:port", } – Toufiq Nov 09 '17 at 10:02
  • Do you have special characters in your username oder password? Maybe you have to escape them? – bastelflp Nov 09 '17 at 13:36
  • code session.auth = HTTPBasicAuth('username', 'passwd') i was using is for the authentication of the SOAP server. – Toufiq Nov 09 '17 at 23:39
  • Could you pls construct the code so that we are on the same page? – Toufiq Nov 09 '17 at 23:51
  • I dont have any special character in my username or passwd – Toufiq Nov 10 '17 at 00:14
  • Is the page https? The error on port 443 is usually due to a ssl / https problem. – bastelflp Nov 11 '17 at 15:55