PascalMinder / geoblock

Traefik middleware plugin - Deny requests based on country of origin
105 stars 9 forks source link

Timeout problems with http-calls to geojs-API #14

Closed toddietaste closed 2 years ago

toddietaste commented 2 years ago

Hi, big thanks for providing this plugin!

I am frequently seeing errors in my traefik log because GeoBlock is running into timeouts when calling the geojs-API:

time="2022-03-30T22:42:40Z" level=error msg="2022/03/30 22:42:40 Get \"https://get.geojs.io/v1/ip/country/51.254.49.108\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)" module=github.com/PascalMinder/GeoBlock plugin=plugin-GeoBlock

The http-timeout for API-calls currently seems to be hardcoded to 750ms in the CallGeoJS function, which may not be sufficient for all environments. It definitely isn't for mine :(

> time curl https://get.geojs.io/v1/ip/country/51.254.49.108
FR

real    0m3.227s
user    0m0.062s
sys 0m0.019s

Would be great to have the http-timeout configurable, i.e. by adding a new (optional) config like 'apiTimeoutMs', which would override the current default if set.

Thanks for considering!

PascalMinder commented 2 years ago

Hey, thanks for opening the issue. I'll look into it.

PascalMinder commented 2 years ago

@toddietaste I created a branch for the issue: https://github.com/PascalMinder/GeoBlock/pull/15

toddietaste commented 2 years ago

I tested the api-timeout branch as a local plugin. Works for me!

Tested:

Thanks!

PascalMinder commented 2 years ago

Thank you very much for testing. I released v0.2.2