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

ping-client example is not working properly. #434

Closed
echupriyanov opened this issue Aug 28, 2018 · 4 comments
Closed

ping-client example is not working properly. #434

echupriyanov opened this issue Aug 28, 2018 · 4 comments

Comments

@echupriyanov
Copy link
Contributor

echupriyanov commented Aug 28, 2018

There is an issue with ping-client. It never receives ping to itself.
Enabling trace log reveals following error:

TRACE 2018-08-28T15:49:55Z: libp2p_mplex: Received message: Open { substream_id: 0 }
DEBUG 2018-08-28T15:49:55Z: libp2p_core::upgrade::apply: Error while negotiated protocol upgrade: Custom { kind: Other, error: MultistreamSelectError(IoError(Custom { kind: Other, error: StringError("invalid substream id opened") })) }

Looking further into mplex code shows, that error happens here:

            // Handle substreams opening/closing.
            match elem {
                codec::Elem::Open { substream_id } => {
                    if (substream_id % 2) == (inner.next_outbound_stream_id % 2) {
                        inner.error = Err(IoError::new(IoErrorKind::Other, "invalid substream id opened"));
                        for task in inner.to_notify.drain() {
                            task.1.notify();
                        }
                        return Err(IoError::new(IoErrorKind::Other, "invalid substream id opened"));
                    }

Since in this example we are in dialing mode, mplex attempts to open substream with id 0, advancing inner.next_outbound_stream_id to 2. And when it tries to accept inbound Open request for the substream with id 0 on the same endpoint, we hit "invalid substream id opened" condition.

Not sure at this moment how this problem can be resolved properly.

@tomaka
Copy link
Member

tomaka commented Aug 28, 2018

Coincidentally @twittner and me just discussed this IRL.

It appears that the JS implementation, which the Rust implementation is based upon, was actually not conforming to what it should be.

Dialers and listeners are both allowed to open the same substream, and they are differentiated by flags.

@twittner
Copy link
Contributor

cf. libp2p/mplex#3 and libp2p/go-mplex#26

@twittner twittner mentioned this issue Aug 30, 2018
@twittner
Copy link
Contributor

twittner commented Sep 6, 2018

@echupriyanov: With #436 being merged, would you mind testing this again?

@echupriyanov
Copy link
Contributor Author

@twittner Thanks! Example is now working perfectly!

@twittner twittner closed this as completed Sep 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants