diff --git a/app/src/main/java/de/westnordost/streetcomplete/data/OsmModule.java b/app/src/main/java/de/westnordost/streetcomplete/data/OsmModule.java index 7d545e672d..223990aea8 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/data/OsmModule.java +++ b/app/src/main/java/de/westnordost/streetcomplete/data/OsmModule.java @@ -64,19 +64,29 @@ public static OsmConnection osmConnection(OAuthConsumer consumer) return new OsmMapDataFactory(); } + public static int defaultOverpassTimeoutInMiliseconds(){ + // see https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#timeout: + // default value is 180 seconds + // give additional 4 seconds to get and process refusal from Overpass + // or maybe a bit late response rather than trigger timeout exception + return (180 + 4) * 1000; + } + @Provides public static OverpassMapDataDao overpassMapDataDao( Provider parserProvider, SharedPreferences prefs) { + Integer timeout = defaultOverpassTimeoutInMiliseconds(); OsmConnection overpassConnection = new OsmConnection( - prefs.getString(Prefs.OVERPASS_URL, OVERPASS_API_WITH_ATTIC_DATA_URL), ApplicationConstants.USER_AGENT, null); + prefs.getString(Prefs.OVERPASS_URL, OVERPASS_API_WITH_ATTIC_DATA_URL), ApplicationConstants.USER_AGENT, null, timeout); return new OverpassMapDataDao(overpassConnection, parserProvider); } @Provides public static OverpassOldMapDataDao overpassOldMapDataDao( Provider parserProvider, String date) { + Integer timeout = defaultOverpassTimeoutInMiliseconds(); OsmConnection overpassConnection = new OsmConnection( - OVERPASS_API_WITH_ATTIC_DATA_URL, ApplicationConstants.USER_AGENT, null); + OVERPASS_API_WITH_ATTIC_DATA_URL, ApplicationConstants.USER_AGENT, null, timeout); return new OverpassOldMapDataDao(overpassConnection, parserProvider, date); }