private async Task <bool> InitializePeerConnection(Peer candidate) { try { await _localPeer.ConnectAsync(candidate.Node.Id, candidate.Node.Host, candidate.Node.Port); return(true); } catch (NetworkingException) { if (_logger.IsInfoEnabled) { _logger.Info($"Cannot connect to peer, removing from active collection: {candidate.Node.Id.ToString(false)}"); } //TODO think about reconnection logic, e.g. change stats and try again after some time //Removing from active peers _activePeers.TryRemove(candidate.Node.Id, out _); return(false); } catch (Exception e) { if (_logger.IsErrorEnabled) { _logger.Error($"Error trying to initiate connetion with peer: {candidate.Node.Id.ToString(false)}", e); } return(false); } }
private async Task <bool> InitializePeerConnection(Peer candidate) { try { if (_logger.IsTrace) { _logger.Trace($"CONNECTING TO {candidate}"); } candidate.IsAwaitingConnection = true; await _rlpxPeer.ConnectAsync(candidate.Node); return(true); } catch (NetworkingException ex) { if (_logger.IsTrace) { _logger.Trace($"Cannot connect to peer [{ex.NetworkExceptionType.ToString()}]: {candidate.Node:s}"); } return(false); } catch (Exception ex) { if (_logger.IsDebug) { _logger.Error($"Error trying to initiate connection with peer: {candidate.Node:s}", ex); } return(false); } }
private async Task <bool> InitializePeerConnection(Peer candidate) { try { await _localPeer.ConnectAsync(candidate.Node.Id, candidate.Node.Host, candidate.Node.Port); return(true); } catch (NetworkingException ex) { if (_logger.IsInfoEnabled) { _logger.Warn($"Cannot connect to Peer [{ex.NetwokExceptionType.ToString()}]: {candidate.Node.Id}"); } return(false); } catch (Exception e) { if (_logger.IsErrorEnabled) { _logger.Error($"Error trying to initiate connetion with peer: {candidate.Node.Id}", e); } return(false); } }