Catch OpenConnectionError
in swarm.dial_peer
This commit is contained in:
parent
1f76f6ee1b
commit
b9d1875027
|
@ -13,7 +13,11 @@ from libp2p.protocol_muxer.multiselect_client import MultiselectClient
|
||||||
from libp2p.protocol_muxer.multiselect_communicator import MultiselectCommunicator
|
from libp2p.protocol_muxer.multiselect_communicator import MultiselectCommunicator
|
||||||
from libp2p.routing.interfaces import IPeerRouting
|
from libp2p.routing.interfaces import IPeerRouting
|
||||||
from libp2p.stream_muxer.abc import IMuxedConn, IMuxedStream
|
from libp2p.stream_muxer.abc import IMuxedConn, IMuxedStream
|
||||||
from libp2p.transport.exceptions import MuxerUpgradeFailure, SecurityUpgradeFailure
|
from libp2p.transport.exceptions import (
|
||||||
|
MuxerUpgradeFailure,
|
||||||
|
OpenConnectionError,
|
||||||
|
SecurityUpgradeFailure,
|
||||||
|
)
|
||||||
from libp2p.transport.listener_interface import IListener
|
from libp2p.transport.listener_interface import IListener
|
||||||
from libp2p.transport.transport_interface import ITransport
|
from libp2p.transport.transport_interface import ITransport
|
||||||
from libp2p.transport.upgrader import TransportUpgrader
|
from libp2p.transport.upgrader import TransportUpgrader
|
||||||
|
@ -118,7 +122,13 @@ class Swarm(INetwork):
|
||||||
multiaddr = self.router.find_peer(peer_id)
|
multiaddr = self.router.find_peer(peer_id)
|
||||||
# Dial peer (connection to peer does not yet exist)
|
# Dial peer (connection to peer does not yet exist)
|
||||||
# Transport dials peer (gets back a raw conn)
|
# Transport dials peer (gets back a raw conn)
|
||||||
|
try:
|
||||||
raw_conn = await self.transport.dial(multiaddr)
|
raw_conn = await self.transport.dial(multiaddr)
|
||||||
|
except OpenConnectionError as error:
|
||||||
|
logger.debug("fail to dial peer %s over base transport", peer_id)
|
||||||
|
raise SwarmException(
|
||||||
|
"fail to open connection to peer %s", peer_id
|
||||||
|
) from error
|
||||||
|
|
||||||
logger.debug("dialed peer %s over base transport", peer_id)
|
logger.debug("dialed peer %s over base transport", peer_id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user