Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P2P: Provide better log message when unable to resolve host #523

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2791,7 +2791,8 @@ namespace eosio {
c->send_time();
}
} else {
fc_ilog( logger, "connection failed to ${a}, ${error}", ("a", c->peer_address())( "error", err.message()));
fc_ilog(logger, "connection failed to ${a}, ${e}", ("a", c->peer_address())
("e", err == boost::asio::error::not_found ? "Unable to resolve endpoint" : err.message()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little suspicious this isn't the right location for such a test. If we can't resolve any hosts wouldn't this be the right location for handling such a thing?

resolver->async_resolve(host, port,
[resolver, host = host, port = port, peer_address = peer_address, listen_address = listen_address, this]( const boost::system::error_code& err, const tcp::resolver::results_type& results ) {
connection_ptr c = std::make_shared<connection>( peer_address, listen_address );
c->set_heartbeat_timeout( heartbeat_timeout );
std::lock_guard g( connections_mtx );
auto [it, inserted] = connections.emplace( connection_detail{
.host = peer_address,
.c = std::move(c),
.ips = results
});
if( !err ) {
it->c->connect( results );
} else {
fc_wlog( logger, "Unable to resolve ${host}:${port} ${error}",
("host", host)("port", port)( "error", err.message() ) );
it->c->set_state(connection::connection_state::closed);
++(it->c->consecutive_immediate_connection_close);
}

Is it possible when being unable to resolve any hosts async_resolve completes successfully but returns an empty result list? (that seems at odds with documentation, just trying to think how this existing Unable to resolve path isn't getting hit)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. Seems the issue is that we add the connection to the connections index even if it doesn't resolve. Then we use that .ips for reconnection. Seems instead we should attempt to resolve the host on each new re-connection.

c->close( false );
if (my_impl->increment_failed_p2p_connections) {
my_impl->increment_failed_p2p_connections();
Expand Down