Connection reset by Peer

I had opened a ticket about this issue and the support told me to post on this forum.
We’ve been having an issue in one of our development environment, and it is not possible to reproduce it locally
Below is the issue

HTTPSConnectionPool(host=‘api.hubapi.com’, port=443): Max retries exceeded with url: /oauth/v1/access-tokens/[REDACTED] (Caused by ProtocolError(‘Connection aborted.’, ConnectionResetError(104, ‘Connection reset by peer’)))

And we are using the official python library
Here is a sample code causing the issue
We added a retry policy as suggested by another post

from hubspot import Hubspot

hubspot_client = HubSpot(access_token=access_token)
raw_token_info= hubspot_client.oauth.access_tokens_api.get(
 token=self.hubspot_client.access_token,
 _request_timeout=(5, 10),
 )

Hi, @DavidM3 :waving_hand: Thanks for your post! Please note that the Developer Support Community is peer-to-peer based, and all replies are from our community members.

Have you tried using the `requests` library directly? As shown by @zach_threadint in this post? I feel like I’ve seen @SteveHTM offer similar suggestions as well.

Other thoughts:

  • have you tried adding an exponential backoff in your retry strategy?
  • Can you check if this occurs during high-volume API requests that might trigger a rate limit?
  • Have you set up monitoring for network stability when connecting to api.hubspot.com?

Talk soon! — Jaycee

Thanks for your reply, we finally used requests directly. It seems the policy of the official hubspot python to get the token is a little off