Skip to content

Commit

Permalink
stop timeouting after 45 seconds
Browse files Browse the repository at this point in the history
default overpass timeout is 180 seconds
should fix #1010, may help with #1466
  • Loading branch information
matkoniecz committed Jul 6, 2019
1 parent 3c9752e commit 575d46a
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<OverpassMapDataParser> 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<OverpassMapDataParser> 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);
}

Expand Down

0 comments on commit 575d46a

Please sign in to comment.