mirror of https://github.com/oxen-io/oxen-mq.git
Catch connect failures
socket.connect() can throw, e.g. if given an invalid connection address; catch this, log the error, and return a failure condition.
This commit is contained in:
parent
2493e2abd4
commit
8e1b2dffa5
|
@ -104,7 +104,14 @@ LokiMQ::proxy_connect_sn(string_view remote, string_view connect_hint, bool opti
|
|||
LMQ_LOG(debug, to_hex(pubkey), " (me) connecting to ", addr, " to reach ", to_hex(remote));
|
||||
zmq::socket_t socket{context, zmq::socket_type::dealer};
|
||||
setup_outgoing_socket(socket, remote);
|
||||
try {
|
||||
socket.connect(addr);
|
||||
} catch (const zmq::error_t& e) {
|
||||
// Note that this failure cases indicates something serious went wrong that means zmq isn't
|
||||
// even going to try connecting (for example an unparseable remote address).
|
||||
LMQ_LOG(error, "Outgoing connection to ", addr, " failed: ", e.what());
|
||||
return {nullptr, ""s};
|
||||
}
|
||||
peer_info p{};
|
||||
p.service_node = true;
|
||||
p.pubkey = std::string{remote};
|
||||
|
|
Loading…
Reference in New Issue