diff options
author | Keith Packard <keithp@keithp.com> | 2018-10-06 22:25:48 -0600 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2018-10-06 22:25:48 -0600 |
commit | 026c735393f6029d09011dba1d5c780322921921 (patch) | |
tree | 42f7e59993449612126936966972868abedb0f4e /map-server | |
parent | e7c0bcd945f8365e86e99b9d450f3a3389fa0e66 (diff) |
altos-map: Retry connection to cache service
Just in case the cache service gets busy, retry the connection instead
of immediately failing.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'map-server')
-rw-r--r-- | map-server/altos-map/AltosMap.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/map-server/altos-map/AltosMap.java b/map-server/altos-map/AltosMap.java index 380556f4..d78396d0 100644 --- a/map-server/altos-map/AltosMap.java +++ b/map-server/altos-map/AltosMap.java @@ -109,7 +109,17 @@ public class AltosMap { fail(400, "Missing zoom"); try { - Socket socket = new Socket(InetAddress.getLoopbackAddress(), port); + Socket socket = null; + int tries = 0; + + while (tries < 10 && socket == null) { + try { + socket = new Socket(InetAddress.getLoopbackAddress(), port); + } catch (IOException ie) { + Thread.sleep(100); + tries++; + } + } AltosJson request = new AltosJson(); |