Giter Site home page Giter Site logo

Comments (7)

derhuerst avatar derhuerst commented on June 11, 2024 1

I'll close this Issue, given that I don't have control over how HaCon and/or DB run the HAFAS endpoint.

You're very welcome to post more findings about the ECONNRESET errors though!

from hafas-client.

VanDerLars avatar VanDerLars commented on June 11, 2024 1

@derhuerst thanks for the tipp.

@Issam-Jendoubi could ne a better approach, let's discuss that.

from hafas-client.

derhuerst avatar derhuerst commented on June 11, 2024

ECONNRESET is the error code that Node.js returns if the TCP has been closed unexpectedly, usually either due to a lossy connection or due to a firewall closing it or dropping packets.

It might be that they're rate-limiting requests from your servers' IP addresses. I've observed similar behaviour with my servers.

I would suggest

  • checking how many requests you're actually sending to them.
  • investigating if this error appears with specific requests (e.g. specific HAFAS methods or specific stop IDs) only, in oder to rule out other possible causes.
  • implementing a caching mechanism. – You could use cached-hafas-client, but it has rather conservative default TTLs, so consider tweaking them.
  • possibly requesting from more IP addresses.

Also we monitor the Hafas Endpoint of Deutsche Bahn (reiseauskunft.bahn.de) with updown.io. The availability constantly got worse over the last weeks.

Do you monitor their endpoint directly, or do you monitor your API which pings their endpoint?

from hafas-client.

Issam-Jendoubi avatar Issam-Jendoubi commented on June 11, 2024

Do you monitor their endpoint directly, or do you monitor your API which pings their endpoint?

We monitor their endpoint directly.

Actually, we were able to reproduce the issue locally. So, it seems that even if they have rate-limiting, it is not IP-based.

from hafas-client.

derhuerst avatar derhuerst commented on June 11, 2024

Actually, we were able to reproduce the issue locally. So, it seems that even if they have rate-limiting, it is not IP-based.

I'm not entirely sure about this. I've definitely run into IP-based rate limits even while developing locally, albeit with many requests. There might also be multiple limits in place, based on multiple factors.

from hafas-client.

VanDerLars avatar VanDerLars commented on June 11, 2024

what we see:

  • ECONRESET seemingly happens randomly
  • exact same request sometimes work, sometimes not
  • no matter if we run it locally or in production, so there's no IP blocking
  • there might be an algorithm when ECONRESET happens, but we see no pattern
  • we "solved" by just retrying the same calls. the second, least the third attempt mostly work

from hafas-client.

derhuerst avatar derhuerst commented on June 11, 2024

we "solved" by just retrying the same calls. the second, least the third attempt mostly work

Note that hafts-client provides retry.js for this. Its current logic merely aborts on ENOTFOUND errors and retries otherwise:

hafas-client/retry.js

Lines 15 to 31 in 4cb7062

const retryingRequest = (...args) => {
const attempt = () => {
return request(...args)
.catch((err) => {
if (err.isHafasError) throw err // continue
if (err.code === 'ENOTFOUND') { // abort
const abortErr = new retry.AbortError(err)
Object.assign(abortErr, err)
throw abortErr
}
throw err // continue
})
}
return retry(attempt, retryOpts)
}
return {

from hafas-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.