litep2p icon indicating copy to clipboard operation
litep2p copied to clipboard

Multiple responses for one request, and their order

Open Ma233 opened this issue 1 year ago • 2 comments

Hello, I am setting up a data forwarding network using litep2p. May I ask a question about the RequestResponse protocol behavior.

Does the RequestResponse protocol support sending multiple responses from the response side for one request? If so, will these responses be received in sequence by the requesting side?

Ma233 avatar Jun 15 '24 12:06 Ma233

The connection closed after sending one response.

Fortunately, according to the libp2p specification (https://docs.libp2p.io/concepts/fundamentals/protocols/#binary-streams), the data is read in the same order as it was written. (I believe litep2p's transport follows it. 😉)

A customized protocol can be achieved by referring to the custom_protocol example and the implementation of RequestResponseProtocol.

Ma233 avatar Jun 26 '24 00:06 Ma233

Yes, request-response protocol only allows sending one response per request. Basically, a new substream is opened for every request and closed after receiving the response.

dmitry-markin avatar Jun 26 '24 07:06 dmitry-markin