Skip to content

No error returned when client 's socket fd is invalid #310

@gxxxh

Description

@gxxxh

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions