# HG changeset patch # User Matthew Wild # Date 1519658487 0 # Node ID 5e9c87376891290b9d786c4c62b1d37cc6920ec7 # Parent d66916dc318ac711d9c82cf70bcb145d4b0e8ac4 net.connect: Handle case when resolver runs out of targets diff -r d66916dc318a -r 5e9c87376891 net/connect.lua --- a/net/connect.lua Mon Feb 26 15:20:35 2018 +0000 +++ b/net/connect.lua Mon Feb 26 15:21:27 2018 +0000 @@ -27,6 +27,14 @@ p.conn = nil; end p.target_resolver:next(function (conn_type, ip, port, extra) + if not conn_type then + -- No more targets to try + p:log("debug", "No more connection targets to try"); + if p.listeners.onfail then + p.listeners.onfail(p.data, p.last_error or "unable to connect to service"); + end + return; + end p:log("debug", "Next target to try is %s:%d", ip, port); local conn = assert(server.addclient(ip, port, pending_connection_listeners, p.options.pattern or "*a", p.options.sslctx, conn_type, extra)); p.conn = conn;