Hi All, I am using OSM maps in my application and download tiles from tile https://tile.openstreetmap.org/. I am using WebClient to download the tile from OSM server. It is worked perfectly before 5 days. But suddenly, tiles not downloaded from server and maps not displayed in my application. I used below code to download tile. imageBytes = await webClient.DownloadDataTaskAsync(imageUri); I have checked the source and getting the below exception in try catch. The remote server returned an error: (403) Forbidden. To resolve this, i set the below properties as true but still maps not displayed in my application. webClient.UseDefaultCredentials = true; webClient.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials; Any one please help me to resolve this issue. Regards, Bharathi. asked 16 Mar '21, 14:59 Bharathirajak |
You are probably not following the tile usage policy found here: https://operations.osmfoundation.org/policies/tiles/ Esp. you'll need a User-Agent that is not generic but specific to your application and also adhere to the other Technical Usage Requirements (see policy document). You'll also have to follow the bulk downloading restrictions (not loading more than 250 tiles from zoom 13 or grater). Best idea would be to use one of external tile providers if it is for a commercial application that needs reliability or - if that's not the case - try to follow the technical requirements from the usage policy. And Frederiks question is still valid: how many tiles has your app loaded already? If those numbers are too high, you may get blocked as well. answered 17 Mar '21, 08:35 Spiekerooger Hi Spiekerooger, Thanks for your update. But, it is reproduced in simple sample. Just downloaded a single tile statically in this. Please find the sample link.
(17 Mar '21, 11:19)
Bharathirajak
4
Sorry, but you did not answer any of the questions above. Again: your application got blocked in accessing tiles because it does not follow the tile usage policy. That's why you get a http 403 error. So: do you use a unique user-agent string? How many tile requests do you send on average and how many tile requests did you sent already? And looking at your code: you are faking a generic user-agent. In doing so, you get blocked.
(17 Mar '21, 11:29)
Spiekerooger
Thanks for your answer and confirm the problem is related to User-Agent that is not generic. I have created Xamarin mobile app to show the OSM map. I will request tile server for each pinch zooming on map based on the zooming level. I don’t know exactly how many requests given already; it is depending on application testing usage. Can you please let me know how to pass valid and generic user agent? it's related to the OSM usage policy.?
(17 Mar '21, 14:17)
Bharathirajak
|
Can you estimate how many tiles you have downloaded in this way?
It is not working for first level itself. It has just 4 tiles
But you said it worked 5 days ago. How many tiles have you downloaded in this way in the last couple of months until it stopped working?
I think the problem is not related to downloading more tiles. Because the issue can be reproduced in simple sample itself by using the above code to download tiles. I have tested with simple sample and different machine and devices.
This issue particularly reproduced when using web client in Xamarin.Forms Android and iOS. In Forms.UWP, we directly used url to image source and it is working fine.