Skip to main content
Solved

Identify API: 104 connection reset by peer

  • October 7, 2022
  • 2 replies
  • 413 views

Forum|alt.badge.img+2

Hi, I’m sending a massive number(over 100k) of custom properties through a for loop and python sdk, but this took too much time and got ConnectionResetError(104, 'Connection reset by peer'). I know this is due to some protection from the server, but I don’t know in what condition will trigger this error. So I’m wondering the best practice if I have a lot of data to send.

 

Here’s what I have tried:

  1. sent the data with an array like this, but got a 500 internal server error:
{'token': 'mykey',
'properties': [{'$email': 'e1', 'mylabel': 0.0014},
{'$email': 'e2', 'mylabel': 0.0002}]}
  1. iterated all my data, but somehow got ConnectionResetError:
from klaviyo_sdk import Client
client = Client(private_key, max_delay=5, max_retries=2)

succeed_emails = []
failed_emails = []
for email, label in zip(emails, labels):
data = {
"token": private_key,
"properties": {
"$email": email,
"mylabel": label
}
}
res = client.TrackIdentify.identify_post(data=data)
if res == "0":
failed_emails.append(email)
else:
succeed_emails.append(email)

By the way, this is probably related to this topic.

Thank you!

Best answer by 8ndpoint

I followed the suggestion from the team and it worked, just refreshing client before every request:

from klaviyo_sdk import Client

for email, label in zip(emails, labels):
client = Client(private_key, max_delay=5, max_retries=2)
data = {
"token": private_key,
"properties": {
"$email": email,
"mylabel": label
}
}
res = client.TrackIdentify.identify_post(data=data)

Thanks for quick response!

2 replies

Dov
Forum|alt.badge.img+61
  • Klaviyo Alum
  • 1493 replies
  • October 7, 2022

Hi @8ndpoint,

Thanks for sharing this question with us.

I’ve requested some feedback from our engineering team to get their view on this as well. I’ll post an update when I have one.

Thanks for being a community member.


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 1 reply
  • Answer
  • October 19, 2022

I followed the suggestion from the team and it worked, just refreshing client before every request:

from klaviyo_sdk import Client

for email, label in zip(emails, labels):
client = Client(private_key, max_delay=5, max_retries=2)
data = {
"token": private_key,
"properties": {
"$email": email,
"mylabel": label
}
}
res = client.TrackIdentify.identify_post(data=data)

Thanks for quick response!