From: Keith Packard Date: Sun, 7 Oct 2018 04:25:48 +0000 (-0600) Subject: altos-map: Retry connection to cache service X-Git-Tag: 1.8.7~3^2~27 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=026c735393f6029d09011dba1d5c780322921921 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 --- 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();