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

Proposed fix for OpenStreetMap 429 (Too many requests) #103

Closed
nijsf opened this issue May 31, 2019 · 3 comments
Closed

Proposed fix for OpenStreetMap 429 (Too many requests) #103

nijsf opened this issue May 31, 2019 · 3 comments
Labels

Comments

@nijsf
Copy link

nijsf commented May 31, 2019

Hello @pauldendulk,

I have had problems problems downloading map tiles from the OpenStreetMap tile server. I got a 429 (Too many requests). That can be solved by adding a UserAgent header to the Http requests. I changed the following:

public HttpTileProvider(IRequest request = null, IPersistentCache<byte[]> persistentCache = null,
           Func<Uri, byte[]> fetchTile = null)
       {
           //Add the UserAgent to the request so OpenStreetMap can track usage (and abuse)
           _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("APP NAME GOES HERE");

           _request = request ?? new NullRequest();
           PersistentCache = persistentCache ?? new NullCache();
           _fetchTile = fetchTile ?? FetchTile;
       }

I have confirmed this to solve my issue on Android, where the map tiles were not downloaded, resulting in a white map. However, not sure if this is the right approach. Could you please have a look at it to see if this needs to be added to the BruTile library?

Your help is much appreciated.

@garykindel
Copy link

This problem started to affect me yesterday 30-May-2019. I agree with nijsf with a need to make this enhancement. In the short-term, I am looking to make the following change in fork:
Add an optional parameter added: string appName=null to:
KnownTileSources.Create(...)
HttpTileSource constructors
HttpTileProvider constructor

Applying modifying the defaultrequestheaders only if a value is provided.
if (!String.IsNullOrWhiteSpace(appName)) _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(appName);

@pauldendulk
Copy link
Contributor

I am on a period of low activity since I have other priorities. This is quite a serious issue though.

@pauldendulk
Copy link
Contributor

The fix will be part of 2.1

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

No branches or pull requests

3 participants