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

multistream-select interoperability issue with JS #1241

Closed
tomaka opened this issue Sep 9, 2019 · 5 comments
Closed

multistream-select interoperability issue with JS #1241

tomaka opened this issue Sep 9, 2019 · 5 comments

Comments

@tomaka
Copy link
Member

tomaka commented Sep 9, 2019

When js-libp2p connects to a listener, it starts by sending out /multistream-select/1.0.0, then waits for the remote to send back /multistream-select/1.0.0, then only sends out the requested protocol.

However, the rust-libp2p listener reads /multistream-select/1.0.0, then sends out /multistream-select/1.0.0, but doesn't immediately flush that to the TCP socket. It only flushes after having sent back an answer to the requested protocol.

cc @raulk @romanb

@tomaka
Copy link
Member Author

tomaka commented Sep 9, 2019

The buffering seems to be happening here:

let mut uvi_buf = uvi::encode::u16_buffer();
let uvi_len = uvi::encode::u16(len, &mut uvi_buf);
self.write_buffer.reserve(len as usize + uvi_len.len());
self.write_buffer.put(uvi_len);
self.write_buffer.put(msg);
Ok(AsyncSink::Ready)

Calling start_send only pushes data to a buffer without sending it out immediately.

@romanb
Copy link
Contributor

romanb commented Sep 9, 2019

This was done intentionally in #1212 - However, if js-libp2p behaves this way and generally it is unfortunately not a requirement of the multistream-select 1.0 spec to send the multistream header together with the first multistream-select request (typically a protocol proposal), there is probably no other option than to immediately flush the multistream-select response header on the listener's side in rust-libp2p. 🤷‍♂️

@romanb
Copy link
Contributor

romanb commented Sep 9, 2019

@tomaka If you would want to change that, it is only a matter of changing this line to

self.state = State::Flush { io };

Flush then transitions to RecvMessage.

@raulk
Copy link
Member

raulk commented Sep 9, 2019

cc @AgeManning

@romanb
Copy link
Contributor

romanb commented Sep 23, 2019

Closed by #1245.

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

Successfully merging a pull request may close this issue.

3 participants