Using REST API from Microservice: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

What causes this error Message?

Product/components used and version/fix level are you on:

Backend 1015
UI 1015

Detailed explanation of the problem:

Why do i get this error message on some API queries when using a microservice?
Some queries run smoothly but the ones for downloading from {{url}}/inventory/binaries/403210 give me that error.
When i execute the query from my PC or on an other tenant it worked.

Error messages / full error message screenshot / log fileL

(‘Connection aborted.’, ConnectionResetError(104, ‘Connection reset by peer’))

Is your question related to the free trial, or to a production (customer) instance?

…emea.com

I now know what caused this problem, but i have no explanation for the behavior of the API.

I was querying binaries from Cumulocity IoT via /inventory/binaries.

For downloading the binary i used the url i got in the “self” fragment of the managed object i got as response.
Problem is that the URL is different in different tenants, for whatever reason.

On the tenant where it worked the url in the “self” fragment looked like this:

  • http://cumulocity:8111/inventory/binaries/3475384

Where it doesn’t worked it looked like this:

  • http://t123456789.emea.cumulocity.com/inventory/binaries/403210
  • this returned a 104 Connection reset by peer

I used the service-user of the microservice with basic auth for all these queries. Username with tenant id (base 64 <tendnt id>/<username>:<password>)

Solution:

  • not use the url from the “self” fragment
  • build the url on my on with the “id” fragment to always look like this: http://cumulocity:8111/inventory/binaries/<id>
1 Like

I had the same problem, recently, unfortunately, i don’t have the right answer for that. I would be very interested as well.I would expect someone from Core R&D team or cloudOps can tell us.

The general rule is:

Use internal baseURL(host) cumlocity:8111 , if you access the Cumulocity from a hosted running microservice )

Use external baseURL(host) from (nginx proxy/api gatway/loadbalancer, I don’t know how to call it correctly), if you access Cumulocity from external running microservice

I used also the self link from a resource, however this contains always the external baseURL(host) and can’t be used in any case.

If you use java sdk I suppose the best way to get the baseURL is:

CumulocityClientProperties clientProperties;

clientProperties.getBaseURL()

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.