ttrpc-rust icon indicating copy to clipboard operation
ttrpc-rust copied to clipboard

No error returned when client 's socket fd is invalid

Open gxxxh opened this issue 3 months ago • 1 comments

Which feature do you think can be improved?

I am trying to using ttrpc like this, it works

fn send_request(){
       // Note this is a uds socket here
        let stream =
            UnixStream::connect(&self.socket_path).context("failed to connect to socket")?;

        // Convert to Ttrpc async client
        let ttrpc_client = ttrpc::r#async::Client::new(stream.as_raw_fd());
        let client =TestClient::new(ttrpc_client);
        client.register(ctx.with_timeout(30), req).await;
}

But If I wrap the client init into a function, it will return "ttrpc err: Receive packet timeout Elapsed"

fn init_connect()->Result<TestClient>{
        let stream =
            UnixStream::connect(&self.socket_path).context("failed to connect to socket")?;

        // Convert to Ttrpc async client
        let ttrpc_client = ttrpc::r#async::Client::new(stream.as_raw_fd());
        let client =TestClient::new(ttrpc_client);
        Ok(client)
}

fn send_request(){
         let client =init_connect();
        client.register(ctx.with_timeout(30), req).await;

}

How can it be improved?

I don't understand why, I hope there can be a example of how to use uds socket and how to wrap client in a single fuctioon

Additional Information

Anything else to add?

Before raising this feature request

Have you looked at the limitations document?

gxxxh avatar Sep 24 '25 02:09 gxxxh