Open Ma233 opened 3 months ago
Hi, just to double check, did you try configuring the request-response protocol with a custom timeout? https://github.com/paritytech/litep2p/blob/ebb5f2dc89a65b7b4c67b592c9312f874be4c0fc/src/protocol/request_response/config.rs#L143
It's set by default to 5 seconds.
@dmitry-markin Hi, thanks for your reminder, I have now added this configuration. But there are still disconnections.
After setting the log level to trace, I found a "keep-alive timeout exceeded, downgrading connection" message. I believe this could be the reason.
Yeah, I see, the connection is downgraded if no substream is opened within 5 seconds after creating the connection. This is strange yours get closed, because sending a request over request-response protocol opens a substream.
Are you sure you send a request within 5 seconds of opening the connection? Do you know you can let litep2p establish a connection for you when sending a request using DialOptions::Dial
?
@dmitry-markin I'm sure because the connection is created by invoking send_request
. (I added peer multiaddr before send_request
.)
let request_id = self
.p2p_server
.request_response_handle
.send_request(peer_id, request_data, DialOptions::Dial)
.await?;
If you don't have any other protocols open over the the connection and the request timeouts after the keep-alive timeout is over, the connection will be closed. This is expected behavior.
If you'd wish to keep the connection open, you could introduce a keep-alive protocol which just opens a new substream when a connection is established and keeps that substream open until you explicitly ask that protocol to close it. Maybe this would give the control you want?
@altonen Hi, I opened a pull request #155 to enable timeout configuration of RequestResponseProtocol
to keep-alive.
I'm not sure if this change conforms to the design concept of litep2p. It's only used to describe a direction of solution.
Hello, I am working on a project that using litep2p with its RequestResponse protocol.
I found that the connection will be closed if a response is not sent within 5 seconds.
I have tested both TcpTransport and QuicTransport, and they are all like this.
I am uncertain whether this relates to the issue https://github.com/paritytech/litep2p/issues/131.
Is there a correct way to keep an open connection until it respond a response? It could be manually closed if neccessary.