Hi, I am trying to connect to pinecone using Sagemaker. However, I am getting 104, ‘Connection reset by peer’ error. Below is what I am doing. Can you please help?
!pip install -U pinecone-client[grpc]
import os
from pinecone import Pinecone, ServerlessSpec
# Now do stuff
print(pc.list_indexes().names())
WARNING:urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectionResetError(104, 'Connection reset by peer')': /indexes
WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectionResetError(104, 'Connection reset by peer')': /indexes
WARNING:urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectionResetError(104, 'Connection reset by peer')': /indexes
---------------------------------------------------------------------------
ProtocolError Traceback (most recent call last)
ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
The above exception was the direct cause of the following exception:
MaxRetryError Traceback (most recent call last)
Cell In[26], line 9
4 pc = Pinecone(
5 api_key=api_key
6 )
8 # Now do stuff
----> 9 print(pc.list_indexes().names())
File /opt/conda/lib/python3.10/site-packages/pinecone/control/pinecone.py:397, in Pinecone.list_indexes(self)
353 def list_indexes(self) -> IndexList:
354 """Lists all indexes.
355
356 The results include a description of all indexes in your project, including the
(...)
395
396 """
--> 397 response = self.index_api.list_indexes()
398 return IndexList(response)
File /opt/conda/lib/python3.10/site-packages/pinecone/core/client/api_client.py:772, in Endpoint.__call__(self, *args, **kwargs)
761 def __call__(self, *args, **kwargs):
762 """ This method is invoked when endpoints are called
763 Example:
764
(...)
770
771 """
--> 772 return self.callable(self, *args, **kwargs)
File /opt/conda/lib/python3.10/site-packages/pinecone/core/client/api/manage_indexes_api.py:1100, in ManageIndexesApi.__init__.<locals>.__list_indexes(self, **kwargs)
1096 kwargs['_check_return_type'] = kwargs.get(
1097 '_check_return_type', True
1098 )
1099 kwargs['_host_index'] = kwargs.get('_host_index')
-> 1100 return self.call_with_http_info(**kwargs)
File /opt/conda/lib/python3.10/site-packages/pinecone/core/client/api_client.py:834, in Endpoint.call_with_http_info(self, **kwargs)
830 header_list = self.api_client.select_header_content_type(
831 content_type_headers_list)
832 params['header']['Content-Type'] = header_list
--> 834 return self.api_client.call_api(
835 self.settings['endpoint_path'], self.settings['http_method'],
836 params['path'],
837 params['query'],
838 params['header'],
839 body=params['body'],
840 post_params=params['form'],
841 files=params['file'],
842 response_type=self.settings['response_type'],
843 auth_settings=self.settings['auth'],
844 async_req=kwargs['async_req'],
845 _check_type=kwargs['_check_return_type'],
846 _return_http_data_only=kwargs['_return_http_data_only'],
847 _preload_content=kwargs['_preload_content'],
848 _request_timeout=kwargs['_request_timeout'],
849 _host=_host,
850 collection_formats=params['collection_format'])
File /opt/conda/lib/python3.10/site-packages/pinecone/core/client/api_client.py:409, in ApiClient.call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, async_req, _return_http_data_only, collection_formats, _preload_content, _request_timeout, _host, _check_type)
355 """Makes the HTTP request (synchronous) and returns deserialized data.
356
357 To make an async_req request, set the async_req parameter.
(...)
406 then the method will return the response directly.
407 """
408 if not async_req:
--> 409 return self.__call_api(resource_path, method,
410 path_params, query_params, header_params,
411 body, post_params, files,
412 response_type, auth_settings,
413 _return_http_data_only, collection_formats,
414 _preload_content, _request_timeout, _host,
415 _check_type)
417 return self.pool.apply_async(self.__call_api, (resource_path,
418 method, path_params,
419 query_params,
(...)
427 _request_timeout,
428 _host, _check_type))
File /opt/conda/lib/python3.10/site-packages/pinecone/core/client/api_client.py:196, in ApiClient.__call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, _preload_content, _request_timeout, _host, _check_type)
192 url = _host + resource_path
194 try:
195 # perform request and return response
--> 196 response_data = self.request(
197 method, url, query_params=query_params, headers=header_params,
198 post_params=post_params, body=body,
199 _preload_content=_preload_content,
200 _request_timeout=_request_timeout)
201 except PineconeApiException as e:
202 e.body = e.body.decode('utf-8')
File /opt/conda/lib/python3.10/site-packages/pinecone/core/client/api_client.py:435, in ApiClient.request(self, method, url, query_params, headers, post_params, body, _preload_content, _request_timeout)
433 """Makes the HTTP request using RESTClient."""
434 if method == "GET":
--> 435 return self.rest_client.GET(url,
436 query_params=query_params,
437 _preload_content=_preload_content,
438 _request_timeout=_request_timeout,
439 headers=headers)
440 elif method == "HEAD":
441 return self.rest_client.HEAD(url,
442 query_params=query_params,
443 _preload_content=_preload_content,
444 _request_timeout=_request_timeout,
445 headers=headers)
File /opt/conda/lib/python3.10/site-packages/pinecone/core/client/rest.py:267, in RESTClientObject.GET(self, url, headers, query_params, _preload_content, _request_timeout)
265 def GET(self, url, headers=None, query_params=None, _preload_content=True,
266 _request_timeout=None):
--> 267 return self.request("GET", url,
268 headers=headers,
269 _preload_content=_preload_content,
270 _request_timeout=_request_timeout,
271 query_params=query_params)
File /opt/conda/lib/python3.10/site-packages/pinecone/core/client/rest.py:224, in RESTClientObject.request(self, method, url, query_params, headers, body, post_params, _preload_content, _request_timeout)
221 raise PineconeApiException(status=0, reason=msg)
222 # For `GET`, `HEAD`
223 else:
--> 224 r = self.pool_manager.request(method, url,
225 fields=query_params,
226 preload_content=_preload_content,
227 timeout=timeout,
228 headers=headers)
229 except urllib3.exceptions.SSLError as e:
230 msg = "{0}\n{1}".format(type(e).__name__, str(e))
File /opt/conda/lib/python3.10/site-packages/urllib3/_request_methods.py:110, in RequestMethods.request(self, method, url, body, fields, headers, json, **urlopen_kw)
107 urlopen_kw["body"] = body
109 if method in self._encode_url_methods:
--> 110 return self.request_encode_url(
111 method,
112 url,
113 fields=fields, # type: ignore[arg-type]
114 headers=headers,
115 **urlopen_kw,
116 )
117 else:
118 return self.request_encode_body(
119 method, url, fields=fields, headers=headers, **urlopen_kw
120 )
File /opt/conda/lib/python3.10/site-packages/urllib3/_request_methods.py:143, in RequestMethods.request_encode_url(self, method, url, fields, headers, **urlopen_kw)
140 if fields:
141 url += "?" + urlencode(fields)
--> 143 return self.urlopen(method, url, **extra_kw)
File /opt/conda/lib/python3.10/site-packages/urllib3/poolmanager.py:443, in PoolManager.urlopen(self, method, url, redirect, **kw)
441 response = conn.urlopen(method, url, **kw)
442 else:
--> 443 response = conn.urlopen(method, u.request_uri, **kw)
445 redirect_location = redirect and response.get_redirect_location()
446 if not redirect_location:
File /opt/conda/lib/python3.10/site-packages/urllib3/connectionpool.py:875, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)
870 if not conn:
871 # Try again
872 log.warning(
873 "Retrying (%r) after connection broken by '%r': %s", retries, err, url
874 )
--> 875 return self.urlopen(
876 method,
877 url,
878 body,
879 headers,
880 retries,
881 redirect,
882 assert_same_host,
883 timeout=timeout,
884 pool_timeout=pool_timeout,
885 release_conn=release_conn,
886 chunked=chunked,
887 body_pos=body_pos,
888 preload_content=preload_content,
889 decode_content=decode_content,
890 **response_kw,
891 )
893 # Handle redirect?
894 redirect_location = redirect and response.get_redirect_location()
File /opt/conda/lib/python3.10/site-packages/urllib3/connectionpool.py:875, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)
870 if not conn:
871 # Try again
872 log.warning(
873 "Retrying (%r) after connection broken by '%r': %s", retries, err, url
874 )
--> 875 return self.urlopen(
876 method,
877 url,
878 body,
879 headers,
880 retries,
881 redirect,
882 assert_same_host,
883 timeout=timeout,
884 pool_timeout=pool_timeout,
885 release_conn=release_conn,
886 chunked=chunked,
887 body_pos=body_pos,
888 preload_content=preload_content,
889 decode_content=decode_content,
890 **response_kw,
891 )
893 # Handle redirect?
894 redirect_location = redirect and response.get_redirect_location()
File /opt/conda/lib/python3.10/site-packages/urllib3/connectionpool.py:875, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)
870 if not conn:
871 # Try again
872 log.warning(
873 "Retrying (%r) after connection broken by '%r': %s", retries, err, url
874 )
--> 875 return self.urlopen(
876 method,
877 url,
878 body,
879 headers,
880 retries,
881 redirect,
882 assert_same_host,
883 timeout=timeout,
884 pool_timeout=pool_timeout,
885 release_conn=release_conn,
886 chunked=chunked,
887 body_pos=body_pos,
888 preload_content=preload_content,
889 decode_content=decode_content,
890 **response_kw,
891 )
893 # Handle redirect?
894 redirect_location = redirect and response.get_redirect_location()
File /opt/conda/lib/python3.10/site-packages/urllib3/connectionpool.py:845, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)
842 elif isinstance(new_e, (OSError, HTTPException)):
843 new_e = ProtocolError("Connection aborted.", new_e)
--> 845 retries = retries.increment(
846 method, url, error=new_e, _pool=self, _stacktrace=sys.exc_info()[2]
847 )
848 retries.sleep()
850 # Keep track of the error for the retry warning.
File /opt/conda/lib/python3.10/site-packages/urllib3/util/retry.py:515, in Retry.increment(self, method, url, response, error, _pool, _stacktrace)
513 if new_retry.is_exhausted():
514 reason = error or ResponseError(cause)
--> 515 raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
517 log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)
519 return new_retry
MaxRetryError: HTTPSConnectionPool(host='api.pinecone.io', port=443): Max retries exceeded with url: /indexes (Caused by ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')))
pc = Pinecone(
api_key=api_key
)
# Now do stuff
print(pc.list_indexes().names())