<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: API Contacts: Remote end closed connection without response in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/558302#M50171</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/310072"&gt;@camera&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From my searches, this appears to be a python bug perhaps &lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/193060"&gt;@JBeatty&lt;/a&gt; , &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/199512"&gt;@BJacobson&lt;/a&gt;&amp;nbsp; either of you run into this before?&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jan 2022 16:17:33 GMT</pubDate>
    <dc:creator>dennisedson</dc:creator>
    <dc:date>2022-01-18T16:17:33Z</dc:date>
    <item>
      <title>API Contacts: Remote end closed connection without response</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/556981#M50131</link>
      <description>&lt;P&gt;Hello people!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm doing some requests to the Contacts endpoint to get all of my contacts. But, sometimes I get an error that I can't handle. I think that the server isn't responding to my request.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are a lot of contacts (700k) and I'm running the code below in a for iteration.&lt;/P&gt;&lt;P&gt;I know about the rate limits, and I'm sure I'm not passing thru.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;url = 'https://api.hubapi.com/crm/v3/objects/contacts'

headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + &amp;lt;token&amp;gt;
}

params = {
'limit': 100,
'properties': &amp;lt;list of properties&amp;gt;,
'after': &amp;lt;next_paging number&amp;gt;
}

response = requests.get(url=url, headers=headers, params=params)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sometimes I get the error below, sometimes I don't.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

http.client.RemoteDisconnected: Remote end closed connection without response

urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've summarized the error so it doesn't get too big.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me, please?&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jan 2022 02:49:15 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/556981#M50131</guid>
      <dc:creator>camera</dc:creator>
      <dc:date>2022-01-16T02:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: API Contacts: Remote end closed connection without response</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/558302#M50171</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/310072"&gt;@camera&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From my searches, this appears to be a python bug perhaps &lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/193060"&gt;@JBeatty&lt;/a&gt; , &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/199512"&gt;@BJacobson&lt;/a&gt;&amp;nbsp; either of you run into this before?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 16:17:33 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/558302#M50171</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2022-01-18T16:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: API Contacts: Remote end closed connection without response</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/560047#M50251</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/13982"&gt;@dennisedson&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for reply! It's not a python bug.&amp;nbsp;It's about the non-response of some messages by Hubspot's API server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made some improvements in the API request in the python script. I configured the retry factor from the urllib3 library (&lt;A href="https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#module-urllib3.util.retry" target="_blank"&gt;https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#module-urllib3.util.retry&lt;/A&gt;) and now my pipeline it's not crashing anymore.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, even so, I would like to know why the Hubspot API server is not answer some of my requests...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 17:59:27 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/560047#M50251</guid>
      <dc:creator>camera</dc:creator>
      <dc:date>2022-01-20T17:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: API Contacts: Remote end closed connection without response</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/684750#M56238</link>
      <description>&lt;P&gt;I came accross this issue also; would there be a way to solve it? Our syncs take a long time since we need to iterate through all of our associations, and this is making our ETL tool fail&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 19:15:58 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/684750#M56238</guid>
      <dc:creator>SBurwash</dc:creator>
      <dc:date>2022-08-24T19:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: API Contacts: Remote end closed connection without response</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/1054769#M77379</link>
      <description>&lt;P&gt;I'm encountering the same issue today:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even after using the provided sample from here: &lt;A href="https://github.com/HubSpot/sample-apps-retry-middleware/blob/main/python/cli.py" target="_new" rel="noopener"&gt;&lt;SPAN&gt;https&lt;/SPAN&gt;&lt;SPAN&gt;://github&lt;/SPAN&gt;&lt;SPAN&gt;.com&lt;/SPAN&gt;&lt;SPAN&gt;/HubSpot&lt;/SPAN&gt;&lt;SPAN&gt;/sample&lt;/SPAN&gt;&lt;SPAN&gt;-apps&lt;/SPAN&gt;&lt;SPAN&gt;-retry&lt;/SPAN&gt;&lt;SPAN&gt;-middleware&lt;/SPAN&gt;&lt;SPAN&gt;/blob&lt;/SPAN&gt;&lt;SPAN&gt;/main&lt;/SPAN&gt;&lt;SPAN&gt;/python&lt;/SPAN&gt;&lt;SPAN&gt;/cli&lt;/SPAN&gt;&lt;SPAN&gt;.py&lt;/SPAN&gt;&lt;/A&gt;, the error persists, particularly with status 429 or "RemoteDisconnected."&lt;/P&gt;&lt;P&gt;Here’s my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from urllib3.util import Retry
from requests.adapters import HTTPAdapter
import requests
from hubspot import HubSpot

# Create a HubSpot client with retry logic
def create_client(api_key):
    # Set interval based on environment
    if environment == "sb":  # Sandbox
        interval = 6  # 6 seconds for free plan
    else:  # Production
        interval = 1  # 1 second for pro plan

    # Define the retry strategy
    retry_strategy = Retry(
        total=5,  # Total number of retries
        backoff_factor=interval,  # Exponential backoff
        status_forcelist=[429, 500, 502, 504],  # Status codes to retry
        allowed_methods=["HEAD", "GET", "OPTIONS", "POST", "PUT"],  # Methods for retry
        raise_on_status=False  # Don't raise error after final retry
    )

    # Create an HTTP adapter with the retry strategy
    adapter = HTTPAdapter(max_retries=retry_strategy)

    # Create a session and mount the adapter
    http = requests.Session()
    http.mount("https://", adapter)
    http.mount("http://", adapter)

    # Update session headers with API token
    http.headers.update(
        {"Content-Type": "application/json", "Authorization": f"Bearer {api_key}"}
    )

    return HubSpot(access_token=api_key, http=http)

# Create HubSpot API clients for different calls
api_client_companies = create_client(get_access_token("HUBSPOT_COMPANIES", "companies"))
api_client_contacts = create_client(get_access_token("HUBSPOT_CONTACTS", "contacts"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Could anyone share insights or suggest further improvements? Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 18:14:23 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/1054769#M77379</guid>
      <dc:creator>GAlinio</dc:creator>
      <dc:date>2024-10-14T18:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: API Contacts: Remote end closed connection without response</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/1054792#M77380</link>
      <description>&lt;P&gt;Hey there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Founder at Stacksync here. &lt;EM&gt;&lt;STRONG&gt;RemoteDisconnected&lt;/STRONG&gt;&lt;/EM&gt; is a common HubSpot error that can happen for a variety of reasons, coming due to HubSpot issues (most often) or sometimes network issues depending on how reliable is your cloud provider and network tier.&lt;/P&gt;&lt;P&gt;At Stacksync, we have several parallel data read/write processed for a single HubSpot instance. We have implemented a retry module on the API call with exponential backoff delays. It ensures that you do not exceed rate limits, as well as being robust to repeated&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;RemoteDisconnected&lt;/STRONG&gt;&lt;/EM&gt; errors (the error can happen sometimes 1-4 times in a row, and this can lead to coordination issues between processes if you parallellize queries).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For context, Stacksync powers real-time and bidirectional sync between HubSpot and Databases like Postgres, Snowflake, BigQuery, MySQL and more.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 18:58:52 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/1054792#M77380</guid>
      <dc:creator>RubenBurdin</dc:creator>
      <dc:date>2024-10-14T18:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: API Contacts: Remote end closed connection without response</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/1054836#M77383</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/537570"&gt;@RubenBurdin&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thank you for your response about the RemoteDisconnected error in HubSpot. I appreciate the information on how Stacksync handles parallel data processing and the retry module. It’s very helpful for improving my script.&amp;nbsp;I have a few quick questions:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Can you share more details about how you implemented the retry module? Any best practices or specific libraries you recommend?&lt;/LI&gt;&lt;LI&gt;Could you provide examples of how you manage rate limits effectively in a high-volume environment?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I look forward to using these strategies in my setup.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;BR /&gt;Gerald&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 21:01:17 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/1054836#M77383</guid>
      <dc:creator>GAlinio</dc:creator>
      <dc:date>2024-10-14T21:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: API Contacts: Remote end closed connection without response</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/1056122#M77455</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/712917"&gt;@GAlinio&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Unsure I fully understand the question here. Would you like to see code or architecture?&lt;/P&gt;&lt;P&gt;Happy to chat about it at &lt;A href="https://cal.com/rubenburdin/20min" target="_blank"&gt;https://cal.com/rubenburdin/20min&lt;/A&gt;&amp;nbsp;(feel free to book anytime) if you wanna deep dive together into the topic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2024 21:46:42 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/1056122#M77455</guid>
      <dc:creator>RubenBurdin</dc:creator>
      <dc:date>2024-10-16T21:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: API Contacts: Remote end closed connection without response</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/1103330#M80069</link>
      <description>&lt;P&gt;This article solved it for me&amp;nbsp;&lt;A href="https://www.stacksync.com/blog/explaining-hubspots-remotedisconnected-error" target="_blank"&gt;https://www.stacksync.com/blog/explaining-hubspots-remotedisconnected-error&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 18:31:11 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/1103330#M80069</guid>
      <dc:creator>RubenBurdin</dc:creator>
      <dc:date>2025-02-03T18:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: API Contacts: Remote end closed connection without response</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/1130366#M81303</link>
      <description>&lt;P&gt;I had the same issue when building our syncs. In custom-code, we had to implement retries (ideally retry 4 times at intervals of 5 seconds). It is possible that the issue still persists after 4 retries altough most case should pass with this simple rule.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since our data was massive and we had to iterate over 200k+ Associations too, we just ended up using Stacksync managed two-way sync with our database (postgres) and it has never failed so far. They manage this issue internally.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 14:45:39 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Contacts-Remote-end-closed-connection-without-response/m-p/1130366#M81303</guid>
      <dc:creator>RubenBurdin</dc:creator>
      <dc:date>2025-04-01T14:45:39Z</dc:date>
    </item>
  </channel>
</rss>

