From 026c735393f6029d09011dba1d5c780322921921 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 6 Oct 2018 22:25:48 -0600 Subject: [PATCH] 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 --- map-server/altos-map/AltosMap.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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(); -- 2.30.2