Question

Possible cause of ESOCKETTIMEDOUT when calling Export API

  • 15 November 2021
  • 5 replies
  • 69 views

Badge

In recent weeks we are increasingly seeing the node js code that pulls events from the Export API failing with ESOCKETTIMEDOUT. The code calls the export API asynchronously once a day to retrieve 24 hours worth of events, leaving a gap of about 4 hours to try to get around the fact that the API will fail with a 404 if the final hour/s are not present.

 

This is not listed as one of the errors that one might receive from the export API :

 

It is as if the export API is rejecting the request, or that DNS is failing to resolve. However I can subsequently trigger the task manually and it runs without error.

I did not think that this would be due to either missing data based on the time range requested or the data size, because these are supposed to return specific errors, and I have seen the 404 error on previous occasions (which is another thing: why can’t the APi just return the data that it actually has for the date range requested, even if it has nothing for only the final hour of the request?).

 

 


5 replies

Userlevel 4
Badge +2

Hi @MelissaSnell ,

 

Thanks for writing into Amplitude Community! We appreciate it!

So you are getting this error of ESOCKETTIMEDOUT with the Export API. Is it a possibility that the data being exported is greater than 4GB in size? Is the error response a 404 for this ESOCKETTIMEDOUT or does it have a response code? Do you have any ad blockers or VPNs active? This can also interfere with the API calls.

 

If you can send me the API calls (with API keys removed) and the organization ID, I can look into this and see why this might be happening. How are you calling the API when you do get this error? Is it through Postman or some other library/software? Thank you!

Badge

The error response is not a 404 because I have a specific try/catch that checks for 404 and logs a specific message. According to the error codes if the data is > 4Gb I should get an error 400?

I am calling the export API using axios and node js. The call is asynchronous.

The URL that I am calling is  https://amplitude.com/api/2/export

I will send you the organisation ID in a direct message

 

Userlevel 4
Badge +2

@MelissaSnell 

 

Very true, you would get a 400 error. Thank you for PM’ing your organization ID to me! Would you be able to post the code you are using and some examples where you get this 400 error? Is it always giving this error or does it pass after some time? As in, if you retry it later, does it work?

If you can provide any details of how to reproduce, that would be great along with the code. If you are not comfortable posting it here (which I totally understand), you can PM it to me and it will not be publicly visible :) Thanks Melissa!

Badge

If I manually trigger the code out of schedule it will mostly then work, but the code will be pulling for a different date/time range. 

 

I will send you a PM with the code

Badge

@Denis Holmes hi there. Any news?

Reply