From 333f70120c8c3b6cccf28737c5e230915f5d8f7c Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 22 Aug 2017 12:00:21 +0100 Subject: [PATCH 1/2] http_client: add getters for host and port --- contrib/epee/include/net/http_client.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/epee/include/net/http_client.h b/contrib/epee/include/net/http_client.h index 67e63f7bf..8e099e2bc 100644 --- a/contrib/epee/include/net/http_client.h +++ b/contrib/epee/include/net/http_client.h @@ -293,6 +293,9 @@ using namespace std; , m_lock() {} + const std::string &get_host() const { return m_host_buff; }; + const std::string &get_port() const { return m_port; }; + bool set_server(const std::string& address, boost::optional user) { http::url_content parsed{}; From 64ab88446ae6ca97f3d42e1ce30c946e2fe7c1e8 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 22 Aug 2017 12:00:37 +0100 Subject: [PATCH 2/2] rpc_client: print destination host/port when failing to connect --- src/common/rpc_client.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/rpc_client.h b/src/common/rpc_client.h index 8494b4a60..297020ef2 100644 --- a/src/common/rpc_client.h +++ b/src/common/rpc_client.h @@ -69,7 +69,7 @@ namespace tools bool ok = connection.is_open(); if (!ok) { - fail_msg_writer() << "Couldn't connect to daemon"; + fail_msg_writer() << "Couldn't connect to daemon: " << m_http_client.get_host() << ":" << m_http_client.get_port(); return false; } ok = ok && epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT()); @@ -98,7 +98,7 @@ namespace tools ok = ok && epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT()); if (!ok) { - fail_msg_writer() << "Couldn't connect to daemon"; + fail_msg_writer() << "Couldn't connect to daemon: " << m_http_client.get_host() << ":" << m_http_client.get_port(); return false; } else if (res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ? @@ -126,7 +126,7 @@ namespace tools ok = ok && epee::net_utils::invoke_http_json(relative_url, req, res, m_http_client, t_http_connection::TIMEOUT()); if (!ok) { - fail_msg_writer() << "Couldn't connect to daemon"; + fail_msg_writer() << "Couldn't connect to daemon: " << m_http_client.get_host() << ":" << m_http_client.get_port(); return false; } else if (res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ?