claws / dump1090-exporter

A Prometheus metrics exporter for the dump1090 Mode S decoder for RTLSDR
MIT License
86 stars 18 forks source link

json invalid mime-type #22

Open cranky-coder opened 4 years ago

cranky-coder commented 4 years ago

I am running your docker version of the code running on my ubuntu 18.04 install. I have the piaware docker running on a pi with the aircraft.json and stats.json files exposed via the web interface.

When I run the docker i get the following error.

Error fetching dump1090 aircraft data: Client error 0, message='Attempt to decode JSON with unexpected mimetype: application/octet-stream', url=URL('http://192.168.2.99:8087/data/aircraft.json'), http://192.168.2.99:8087/data/aircraft.json

However, if i put that url in to any browser or use curl it returns the JSON no problem. From what I found in searching around it seems it could be related aiohttp. Seems it's possible to tell it to ignore mime-type. I tried to modify the code and do a build on my env, but was unsuccessful getting a build so i couldn't fully test.

madzodiac commented 1 year ago

I‘ve the same issue. Was this fixed somewhere or by someone?

madzodiac commented 1 year ago

I‘ve the same issue. Was this fixed somewhere or by someone?

I looked to the error messages as well as some code fragments in https://github.com/claws/dump1090-exporter/blob/master/src/dump1090exporter/exporter.py Probably this needs a json mime type as input and not plain text: data = await resp.json() Would it be feasible to change this to .text instead of .json? see also https://dmitripavlutin.com/javascript-fetch-async-await/

MaxWinterstein commented 1 year ago

@madzodiac good start, but you mixed up Python and Javascript 😉

Your mentioned data = await resp.json() is the right place to change, see my #42