public-transport / hafas-client

JavaScript client for HAFAS public transport APIs.
ISC License
278 stars 54 forks source link

BVG client is failing to fetch data #257

Closed smellouk closed 2 years ago

smellouk commented 2 years ago

Hi :wave:,

I'm using this MagicMirror module, this last is using hafas-client which is failing to fetch data, I think it's related to the client.

The error is:

[ERROR] Error initializing fetcher: TypeError: Cannot read property 'getStationName' of undefined
[11.01.2022 07:12.13.397] [ERROR] Error initializing fetcher: FetchError: request to https://bvg-apps.hafas.de/bin/mgate.exe? failed, reason: getaddrinfo EAI_AGAIN bvg-apps.hafas.de bvg-apps.hafas.de:443
[11.01.2022 07:12.13.480] [ERROR] { FetchError: request to https://bvg-apps.hafas.de/bin/mgate.exe? failed, reason: getaddrinfo EAI_AGAIN bvg-apps.hafas.de bvg-apps.hafas.de:443
    at ClientRequest.<anonymous> (/home/pi/MagicMirror/modules/MMM-PublicTransportBerlin/node_modules/node-fetch/lib/index.js:1483:11)
    at ClientRequest.emit (events.js:198:13)
    at TLSSocket.socketErrorListener (_http_client.js:401:9)
    at TLSSocket.emit (events.js:198:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  message:
   'request to https://bvg-apps.hafas.de/bin/mgate.exe? failed, reason: getaddrinfo EAI_AGAIN bvg-apps.hafas.de bvg-apps.hafas.de:443',
  type: 'system',
  errno: 'EAI_AGAIN',
  code: 'EAI_AGAIN' }
derhuerst commented 2 years ago

Hey,

[ERROR] Error initializing fetcher: TypeError: Cannot read property 'getStationName' of undefined

This error seems to be either unrelated, or caused by the actual cause. I suspect that somewhere in the Magic Mirror module code, the hafas-client fetch error is not fully handled.

[11.01.2022 07:12.13.397] [ERROR] Error initializing fetcher: FetchError: request to https://bvg-apps.hafas.de/bin/mgate.exe? failed, reason: getaddrinfo EAI_AGAIN bvg-apps.hafas.de bvg-apps.hafas.de:443

EAI_AGAIN means the DNS server replied that it cannot currently fulfill the request. Can you confirm that this issue didn't occur due to a flaky internet connection? If yes, it probably happened because the APIs DNS server blocked your IP address because of too much traffic.

https://github.com/deg0nz/MMM-PublicTransportBerlin/pull/67 will probably help with this, but I should also check if hafas-client does a DNS lookup on every request.

smellouk commented 2 years ago

@derhuerst thank you :pray:, I will restart my modem and try again.

Closing the issue.