mixpanel / mixpanel-java

Other
49 stars 37 forks source link

HTTP response code 408 when using deliver (batch) #14

Open chook opened 9 years ago

chook commented 9 years ago

I'm getting: java.io.IOException: Server returned HTTP response code: 408 for URL: http://api.mixpanel.com/track?ip=0

arittr commented 9 years ago

hey @chook - what are you POST-ing over to us here? my thought is that either the batch is too big (over 50 events) or that there's something malformed being sent over. it's also possible the data payload is empty, which could cause the server to timeout waiting for the data to be sent. any of this seem possible? feel free to email me directly at drew [at] mixpanel if you want to send over the actual event data.

chook commented 9 years ago

I've checked this, it appears we are sending data (not empty) and the data payload isn't too large. Today I got Server returned HTTP response code: 408 for URL: http://api.mixpanel.com/engage

For a delivery of 29 people messages.

Is it possible we are hitting your API too fast and you are throttling us, resulting in 408 responses?

Furthermore, the way we do it is we add mixpanel changes we want to a queue, and have a daemon thread that drains it and send the requests - giving it the async nature we need.

Is it possible the JSONObjects created by the library should be delivered close to the time they are created and the problem lies in the time they spend in the queue?

joeatwork commented 9 years ago

This is great information! (thanks for catching the reference to the new issue!)

joeatwork commented 9 years ago

@espiegel, you can follow progress on this issue here (rather than in #15 )

Thanks!

joeatwork commented 9 years ago

My current suspicion is that the time required to encode and write the data in the library is too long. It shouldn't be an issue with the queue- the tracking endpoint should accept events up to five days old. My guess is that the time interval between opening the connection and writing data is too long. I'll try to reproduce it here.

URLConnection conn = endpoint.openConnection();
// My *guess* is that we're doing too much work here for large deliveries
postStream = conn.getOutputStream();
postStream.write(encodedQuery.getBytes());
JensRantil commented 9 years ago

@joeatwork Follow-up; Were you able to reproduce this?

joeatwork commented 9 years ago

@arittr or @yinfeiru - would you comment on this?

arittr commented 9 years ago

thx @joeatwork - @JensRantil @ryanseams is going to take a look at this