cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
Walkthrough Wednesdays
424
Views
0
Helpful
2
Replies

Python and AXL API, Error: 502 Tunnel Connection Failed

Hello,

I am developing with Python and AXL API, i have trouble connection to CUCM AXL API Call Manager the issue is:

Code:

# -*- coding: utf-8 -*-
from zeep import Client
from zeep.cache import SqliteCache
from zeep.transports import Transport
from zeep.exceptions import Fault
from zeep.plugins import HistoryPlugin
from requests import Session
from requests.auth import HTTPBasicAuth
from urllib3 import disable_warnings
from urllib3.exceptions import InsecureRequestWarning
from lxml import etree
 
disable_warnings(InsecureRequestWarning)
 
username = 'admon'
password = 'ciscopsdt'
# If you're not disabling SSL verification, host should be the FQDN of the server rather than IP
host = '10.10.20.1'
 
#wsdl = 'file://C:/Development/Resources/axlsqltoolkit/schema/current/AXLAPI.wsdl'
wsdl = 'file://C:/Users/HIBARRAR/Documents/SoftM/Cisco DevNet/API CUCM Call Manager/axlsqltoolkit/schema/11.5/AXLAPI.wsdl'
location = 'https://{host}:8443/axl/'.format(host = host)
binding = "{http://www.cisco.com/AXLAPIService/}AXLAPIBinding"
 
# Create a custom session to disable Certificate verification.
# In production you shouldn't do this, 
# but for testing it saves having to have the certificate in the trusted store.
session = Session()
session.verify = False
session.auth = HTTPBasicAuth(username, password)
 
transport = Transport(cache = SqliteCache(), session = session, timeout = 20)
history = HistoryPlugin()
client = Client(wsdl = wsdl, transport = transport, plugins = [history])
service = client.create_service(binding, location)
 
def show_history():
    for item in [history.last_sent, history.last_received]:
        print(etree.tostring(item["envelope"], encoding="unicode", pretty_print=True))

try:
    resp = service.listPhone(searchCriteria={'name': '%'}, 
                             returnedTags={'name': '', 'description': ''})
    print(resp)
except Fault:
    show_history()

Result:

HTTPSConnectionPool(host='XXX.XXX.XXX.XXX, port=8443): 
Max retries exceeded with url: /axl/
(Caused by ProxyError('Cannot connect to proxy.',
OSError('Tunnel connection failed: 502 Tunnel Connection Failed')))
Anyone, can help me?
2 REPLIES 2
Anusha B R
Cisco Employee

Hi,

There could be many reasons for 502 errors like, server might not be reachable from the client, or it might not be able to resolve the server address(FQDN) and so on.

I could find the below link, hope that would give you some ideas in troubleshooting your problem,

https://www.cisco.com/c/en/us/support/docs/security/web-security-appliance/118079-troubleshoot-wsa-00.html

Regards,

dstaudt
Cisco Employee

Trying your code above just now on my PC, seems to work...perhaps something in the environment..?:

 

Ubuntu 19.10

Python 3.7.5

 

Python libraries:

appdirs==1.4.3
attrs==19.3.0
cached-property==1.5.1
certifi==2020.4.5.1
chardet==3.0.4
defusedxml==0.6.0
idna==2.9
isodate==0.6.0
lxml==4.5.0
pkg-resources==0.0.0
pytz==2019.3
requests==2.23.0
requests-toolbelt==0.9.1
six==1.14.0
urllib3==1.25.8
zeep==3.4.0

Content for Community-Ad

This widget could not be displayed.