WebexCommunity / WebexPythonSDK

Work with the Webex APIs in native Python!
https://webexcommunity.github.io/WebexPythonSDK/
MIT License
233 stars 151 forks source link

ConnectionError raised while calling webex api #180

Closed PadminiSivaraj closed 1 year ago

PadminiSivaraj commented 1 year ago

Hello team,

I have been trying to send a msg using webexteamssdk from cisco ios-xe device. But I am encountering a problem with /usr/lib/python3.6/socket.py.

webex and dependencies's version detail: webexteamssdk-1.6.1-py3-none-any requests-2.4.2-py2.py3-none-any requests_toolbelt-0.9.1-py2.py3-none-any PyJWT-1.5.1-py2.py3-none-any future-0.15.0

Following is the terminal output

Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 516, in urlopen body=body, headers=headers) File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 304, in _make_request self._validate_conn(conn)

File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 722, in _validate_conn conn.connect() File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 195, in connect conn = self._new_conn() File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 125, in _new_conn (self.host, self.port), self.timeout, **extra_kw) File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/util/connection.py", line 64, in create_connection for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 362, in send timeout=timeout File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 559, in urlopen _pool=self, _stacktrace=stacktrace) File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/util/retry.py", line 245, in increment raise six.reraise(type(error), error, _stacktrace) File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/packages/six.py", line 309, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 516, in urlopen body=body, headers=headers) File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 304, in _make_request self._validate_conn(conn) File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 722, in _validate_conn conn.connect() File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 195, in connect conn = self._new_conn() File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 125, in _new_conn (self.host, self.port), self.timeout, **extra_kw) File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/util/connection.py", line 64, in create_connection for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', gaierror(-2, 'Name or service not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "test.py", line 37, in api.messages.create(toPersonEmail=email, markdown=message) File "/usr/local/lib/python3.6/site-packages/webexteamssdk/api/messages.py", line 282, in create json_data = self._session.post(API_ENDPOINT, json=post_data) File "/usr/local/lib/python3.6/site-packages/webexteamssdk/restsession.py", line 500, in post kwargs) File "/usr/local/lib/python3.6/site-packages/webexteamssdk/restsession.py", line 353, in request response = self._req_session.request(method, abs_url, kwargs) File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 457, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 569, in send r = adapter.send(request, kwargs) File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 407, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', gaierror(-2, 'Name or service not known')) [guestshell@guestshell valueAdd]$

Awaiting your response

Thanks webexapi_issue

dstaudt commented 1 year ago

The errors suggest that Python is unable to resolve the target hostname (i.e. of the Webex API endpoint) via DNS. Is DNS configured/working on the local device?