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

SwarmException: fail to upgrade mux for peer #429

Open
iljah opened this issue Mar 12, 2021 · 1 comment
Open

SwarmException: fail to upgrade mux for peer #429

iljah opened this issue Mar 12, 2021 · 1 comment

Comments

@iljah
Copy link

iljah commented Mar 12, 2021

Running chat example from checkout few mins ago I get this:

$ python3 chat.py 
Run 'python ./examples/chat/chat.py -p 8001 -d /ip4/127.0.0.1/tcp/8000/p2p/QmSJtxopjtChoT96AiB3ENd2KvEPDWdcbBSFBukd6Q1cFv' on another console.
Waiting for incoming connection...
<Manager[Swarm] flags=SRcfe>: task run[daemon=False] exited with error: fail to upgrade mux for peer QmZYMCjqxeMfHj1ZgcK1uMYBZYKFCB8nH6Uvb9bSPSQHdL
Traceback (most recent call last):
  File "/home/ilja/echo/py-libp2p/libp2p/protocol_muxer/multiselect_communicator.py", line 33, in read
    data = await read_delim(self.read_writer)
  File "/home/ilja/echo/py-libp2p/libp2p/utils.py", line 73, in read_delim
    msg_bytes = await read_varint_prefixed_bytes(reader)
  File "/home/ilja/echo/py-libp2p/libp2p/utils.py", line 58, in read_varint_prefixed_bytes
    len_msg = await decode_uvarint_from_stream(reader)
  File "/home/ilja/echo/py-libp2p/libp2p/utils.py", line 42, in decode_uvarint_from_stream
    byte = await read_exactly(reader, 1)
  File "/home/ilja/echo/py-libp2p/libp2p/io/utils.py", line 21, in read_exactly
    raise IncompleteReadError({"requested_count": n, "received_count": len(data)})
libp2p.io.exceptions.IncompleteReadError: {'requested_count': 1, 'received_count': 0}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ilja/echo/py-libp2p/libp2p/protocol_muxer/multiselect.py", line 84, in handshake
    handshake_contents = await communicator.read()
  File "/home/ilja/echo/py-libp2p/libp2p/protocol_muxer/multiselect_communicator.py", line 36, in read
    raise MultiselectCommunicatorError(
libp2p.protocol_muxer.exceptions.MultiselectCommunicatorError: fail to read from multiselect communicator

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ilja/echo/py-libp2p/libp2p/transport/upgrader.py", line 55, in upgrade_connection
    return await self.muxer_multistream.new_conn(conn, peer_id)
  File "/home/ilja/echo/py-libp2p/libp2p/stream_muxer/muxer_multistream.py", line 70, in new_conn
    transport_class = await self.select_transport(conn)
  File "/home/ilja/echo/py-libp2p/libp2p/stream_muxer/muxer_multistream.py", line 66, in select_transport
    protocol, _ = await self.multiselect.negotiate(communicator)
  File "/home/ilja/echo/py-libp2p/libp2p/protocol_muxer/multiselect.py", line 46, in negotiate
    await self.handshake(communicator)
  File "/home/ilja/echo/py-libp2p/libp2p/protocol_muxer/multiselect.py", line 86, in handshake
    raise MultiselectError() from error
libp2p.protocol_muxer.exceptions.MultiselectError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ilja/echo/py-libp2p/libp2p/network/swarm.py", line 253, in conn_handler
    muxed_conn = await self.upgrader.upgrade_connection(
  File "/home/ilja/echo/py-libp2p/libp2p/transport/upgrader.py", line 57, in upgrade_connection
    raise MuxerUpgradeFailure(
libp2p.transport.exceptions.MuxerUpgradeFailure: failed to negotiate the multiplexer protocol

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ilja/echo/lib64/python3.8/site-packages/async_service/base.py", line 324, in _run_and_manage_task
    await task.run()
  File "/home/ilja/echo/lib64/python3.8/site-packages/async_service/trio.py", line 76, in run
    await self._async_fn(*self._async_fn_args)
  File "/home/ilja/echo/py-libp2p/libp2p/network/swarm.py", line 92, in run
    self.listener_nursery = None
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_core/_run.py", line 741, in __aexit__
    raise combined_error_from_nursery
  File "/home/ilja/echo/py-libp2p/libp2p/transport/tcp/tcp.py", line 43, in serve_tcp
    await trio.serve_tcp(handler, port, host=host, task_status=task_status)
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_highlevel_open_tcp_listeners.py", line 219, in serve_tcp
    await trio.serve_listeners(
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_highlevel_serve_listeners.py", line 121, in serve_listeners
    task_status.started(listeners)
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_core/_run.py", line 741, in __aexit__
    raise combined_error_from_nursery
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_highlevel_serve_listeners.py", line 25, in _run_handler
    await handler(stream)
  File "/home/ilja/echo/py-libp2p/libp2p/transport/tcp/tcp.py", line 47, in handler
    await self.handler(tcp_stream)
  File "/home/ilja/echo/py-libp2p/libp2p/network/swarm.py", line 259, in conn_handler
    raise SwarmException(
libp2p.network.exceptions.SwarmException: fail to upgrade mux for peer QmZYMCjqxeMfHj1ZgcK1uMYBZYKFCB8nH6Uvb9bSPSQHdL
Traceback (most recent call last):
  File "/home/ilja/echo/py-libp2p/libp2p/protocol_muxer/multiselect_communicator.py", line 33, in read
    data = await read_delim(self.read_writer)
  File "/home/ilja/echo/py-libp2p/libp2p/utils.py", line 73, in read_delim
    msg_bytes = await read_varint_prefixed_bytes(reader)
  File "/home/ilja/echo/py-libp2p/libp2p/utils.py", line 58, in read_varint_prefixed_bytes
    len_msg = await decode_uvarint_from_stream(reader)
  File "/home/ilja/echo/py-libp2p/libp2p/utils.py", line 42, in decode_uvarint_from_stream
    byte = await read_exactly(reader, 1)
  File "/home/ilja/echo/py-libp2p/libp2p/io/utils.py", line 21, in read_exactly
    raise IncompleteReadError({"requested_count": n, "received_count": len(data)})
libp2p.io.exceptions.IncompleteReadError: {'requested_count': 1, 'received_count': 0}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ilja/echo/py-libp2p/libp2p/protocol_muxer/multiselect.py", line 84, in handshake
    handshake_contents = await communicator.read()
  File "/home/ilja/echo/py-libp2p/libp2p/protocol_muxer/multiselect_communicator.py", line 36, in read
    raise MultiselectCommunicatorError(
libp2p.protocol_muxer.exceptions.MultiselectCommunicatorError: fail to read from multiselect communicator

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ilja/echo/py-libp2p/libp2p/transport/upgrader.py", line 55, in upgrade_connection
    return await self.muxer_multistream.new_conn(conn, peer_id)
  File "/home/ilja/echo/py-libp2p/libp2p/stream_muxer/muxer_multistream.py", line 70, in new_conn
    transport_class = await self.select_transport(conn)
  File "/home/ilja/echo/py-libp2p/libp2p/stream_muxer/muxer_multistream.py", line 66, in select_transport
    protocol, _ = await self.multiselect.negotiate(communicator)
  File "/home/ilja/echo/py-libp2p/libp2p/protocol_muxer/multiselect.py", line 46, in negotiate
    await self.handshake(communicator)
  File "/home/ilja/echo/py-libp2p/libp2p/protocol_muxer/multiselect.py", line 86, in handshake
    raise MultiselectError() from error
libp2p.protocol_muxer.exceptions.MultiselectError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ilja/echo/py-libp2p/libp2p/network/swarm.py", line 253, in conn_handler
    muxed_conn = await self.upgrader.upgrade_connection(
  File "/home/ilja/echo/py-libp2p/libp2p/transport/upgrader.py", line 57, in upgrade_connection
    raise MuxerUpgradeFailure(
libp2p.transport.exceptions.MuxerUpgradeFailure: failed to negotiate the multiplexer protocol

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "chat.py", line 103, in <module>
    main()
  File "chat.py", line 97, in main
    trio.run(run, *(args.port, args.destination))
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_core/_run.py", line 1896, in run
    raise runner.main_task_outcome.error
  File "chat.py", line 68, in run
    await trio.sleep_forever()
  File "/home/ilja/echo/lib64/python3.8/site-packages/async_generator/_util.py", line 53, in __aexit__
    await self._agen.athrow(type, value, traceback)
  File "/home/ilja/echo/py-libp2p/libp2p/host/basic_host.py", line 118, in run
    yield
  File "/home/ilja/echo/lib64/python3.8/site-packages/async_generator/_util.py", line 53, in __aexit__
    await self._agen.athrow(type, value, traceback)
  File "/home/ilja/echo/lib64/python3.8/site-packages/async_service/trio.py", line 411, in background_trio_service
    await manager.stop()
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_core/_run.py", line 741, in __aexit__
    raise combined_error_from_nursery
  File "/home/ilja/echo/lib64/python3.8/site-packages/async_service/trio.py", line 205, in run
    raise trio.MultiError(
  File "/home/ilja/echo/lib64/python3.8/site-packages/async_service/base.py", line 324, in _run_and_manage_task
    await task.run()
  File "/home/ilja/echo/lib64/python3.8/site-packages/async_service/trio.py", line 76, in run
    await self._async_fn(*self._async_fn_args)
  File "/home/ilja/echo/py-libp2p/libp2p/network/swarm.py", line 92, in run
    self.listener_nursery = None
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_core/_run.py", line 741, in __aexit__
    raise combined_error_from_nursery
  File "/home/ilja/echo/py-libp2p/libp2p/transport/tcp/tcp.py", line 43, in serve_tcp
    await trio.serve_tcp(handler, port, host=host, task_status=task_status)
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_highlevel_open_tcp_listeners.py", line 219, in serve_tcp
    await trio.serve_listeners(
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_highlevel_serve_listeners.py", line 121, in serve_listeners
    task_status.started(listeners)
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_core/_run.py", line 741, in __aexit__
    raise combined_error_from_nursery
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_highlevel_serve_listeners.py", line 25, in _run_handler
    await handler(stream)
  File "/home/ilja/echo/py-libp2p/libp2p/transport/tcp/tcp.py", line 47, in handler
    await self.handler(tcp_stream)
  File "/home/ilja/echo/py-libp2p/libp2p/network/swarm.py", line 259, in conn_handler
    raise SwarmException(
libp2p.network.exceptions.SwarmException: fail to upgrade mux for peer QmZYMCjqxeMfHj1ZgcK1uMYBZYKFCB8nH6Uvb9bSPSQHdL

while in another tab I have (note different address than in output above):

$ python3 chat.py -p 8001 -d /ip4/127.0.0.1/tcp/8000/p2p/Qme8mX
libp2p.exceptions.MultiError: [SwarmException('failed to upgrade security for peer Qme8mX')]

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "chat.py", line 103, in <module>
    main()
  File "chat.py", line 97, in main
    trio.run(run, *(args.port, args.destination))
  File "/home/ilja/echo/lib64/python3.8/site-packages/trio/_core/_run.py", line 1896, in run
    raise runner.main_task_outcome.error
  File "chat.py", line 59, in run
    await host.connect(info)
  File "/home/ilja/echo/py-libp2p/libp2p/host/basic_host.py", line 172, in connect
    await self._network.dial_peer(peer_info.peer_id)
  File "/home/ilja/echo/py-libp2p/libp2p/network/swarm.py", line 142, in dial_peer
    raise SwarmException(
libp2p.network.exceptions.SwarmException: unable to connect to Qme8mX, no addresses established a successful connection (with exceptions)

It more or less works if I use correct address.

@mhchia
Copy link
Contributor

mhchia commented Mar 15, 2021

IIUC it looks like we didn't check the correctness of a dialed peer id both in the Swarm's connection handler and dial_peer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants