Half of API calls end up in Exception: Broken pipe

esokolov
Member

Hi Community, 

Please advice on Exception that happens every second/third API (HTTP) call that we have: 

 

org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://track.hubspot.com/v1/event/": Connection reset; nested exception is javax.net.ssl.SSLException: Connection reset
	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:744)
[...]
Caused by: javax.net.ssl.SSLException: Connection reset
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:127)
[...]
Suppressed: java.net.SocketException: Broken pipe (Write failed)
		at java.base/java.net.SocketOutputStream.socketWrite0(Native Method)

So, the root cause is 'Broken pipe'. Usually, this happens when a connection was closed on one of the ends and somebody tries to write into this connection.

On our side, we use Spring's RestTemplate that doesn't use any pool of connections and starts each time a new connection (so there is nothing to be closed on our side). 

I saw this happened quite regularly for us on different API calls. At least it happened on: 

 

1) HubSpot Events HTTP API:  https://developers.hubspot.com/docs/methods/enterprise_events/http_api  
2) Create or update a contact: https://developers.hubspot.com/docs/methods/contacts/create_or_update
3) Update email subscription status for an email address: https://developers.hubspot.com/docs/methods/email/update_status 

We developed a workaround for this: each call we wrapped into retry block that does up to 3 attempts to succeed with the request. After that, the error disappeared (actually, we simply don't log the error if we managed to succeed in 3 attempts). 

However, could you suggest where the issue is? 

Additionally, please note that: 
1) we did this on a test account 
2) we use apikey integration (oauth isn't completed yet) 
3) we have around  100-200 API over HTTP requests per day


Thank you, 
Evgeniy

0 Upvotes
1 Reply 1
IsaacTakushi
HubSpot Employee

Welcome, @esokolov.

 

Thanks for including all this detail.

 

I'm not well-versed in Java, but in my research, the javax.net.ssl.SSLException: Connection reset exception indicates that the connection was closed on the server end. This could be an issue with the request you are sending or an issue on our end.

 

To eliminate factors, could you make the same requests manually through a REST client like Postman?

 

If these tests are successful, it suggests some issue in the Java code creating an unstable connection.

Isaac Takushi

Alumnus, HubSpot Developer Support
0 Upvotes