Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetcher errors (TypeError, invalid-json) #66

Closed
vwegert opened this issue Jan 8, 2022 · 6 comments · Fixed by #67
Closed

fetcher errors (TypeError, invalid-json) #66

vwegert opened this issue Jan 8, 2022 · 6 comments · Fixed by #67

Comments

@vwegert
Copy link

vwegert commented Jan 8, 2022

After pulling the December changes, I'm seeing the following error multiple times right after MM2 startup:

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

When the UI is loaded, the following errors appear:

[ERROR] FetchError: invalid json response body at https://bvg-apps-ext.hafas.de/bin/mgate.exe? reason: Unexpected end of JSON input
    at /home/magicmirror/MagicMirror/modules/MMM-PublicTransportBerlin/node_modules/node-fetch/lib/index.js:273:32
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async BvgFetcher.getStationName (/home/magicmirror/MagicMirror/modules/MMM-PublicTransportBerlin/BvgFetcher.js:27:19)
    at async Class.createFetcher (/home/magicmirror/MagicMirror/modules/MMM-PublicTransportBerlin/node_helper.js:22:27) {
  type: 'invalid-json'
}
@ahaupt
Copy link

ahaupt commented Jan 9, 2022

Also seeing this, but I'd rather think it's a problem with the BVG api service. See example from https://v5.bvg.transport.rest/api.html

[notebook] ~ % curl 'https://v5.bvg.transport.rest/locations?query=alexanderplatz&results=1'
{
	"message": "invalid json response body at https://bvg-apps-ext.hafas.de/bin/mgate.exe? reason: Unexpected end of JSON input",
	"type": "invalid-json",
	"error": true,
	"msg": "invalid json response body at https://bvg-apps-ext.hafas.de/bin/mgate.exe? reason: Unexpected end of JSON input"
}

@mazim-co
Copy link

mazim-co commented Jan 9, 2022

Same here. Getting the same error above. Any ideas how to fix this?

@deg0nz
Copy link
Owner

deg0nz commented Jan 10, 2022

Thanks for reporting. This looks like an error that is out of our reach. I wasn't able to find an issue ticket in hafas-client.

I will jut ping @derhuerst here, maybe he can help us to narrow this error down.

@derhuerst
Copy link

AFAIK this is due to the user agent that is being passed into hafas-client during initialisation. It seems like BVG or HaCon blocks certain User-Agents, because https://v5.bvg.transport.rest was down and I fixed it by changing the user agent.

@KristjanESPERANTO
Copy link
Collaborator

My PR I improves the situation. But I still get in rare cases the error message FetchError: invalid json response body at https://bvg-apps-ext.hafas.de/bin/mgate.exe? reason: Unexpected end of JSON input. Nevertheless, departures are displayed with this fix.

I suggest not closing this issue yet, even if my PR has been merged. It would be nice if we could find out the cause of the error message.

@deg0nz
Copy link
Owner

deg0nz commented Jan 13, 2022

This issue was closed because of merging #67. Please feel free to open again of you encounter any errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants