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

Custom TCP connect timeout ? #19

Closed
jvelo opened this issue Feb 20, 2019 · 4 comments
Closed

Custom TCP connect timeout ? #19

jvelo opened this issue Feb 20, 2019 · 4 comments

Comments

@jvelo
Copy link

jvelo commented Feb 20, 2019

Hello,

Is it possible to set a custom TCP connect timeout ?
I'm new to rust, I might be missing some things obvious in the way tokio works

If it's not possible and of interest, I'm willing to give it a go.

Thanks!

@flosse
Copy link
Member

flosse commented Feb 28, 2019

@jvelo Sorry for the late reply.
The TCP connection currently is managed by the deprecated tokio-proto crate that no longer is maintained. Unfortunately there is no drop-in replacement for that.
I already ask for a possible replacement more than a year ago (tokio-rs/tokio-proto#202 (comment)) but there is not really a progress on that :(
This is why we're going to remove the dependency entirely. The corresponding issue is discussed in #18
Probably we first will release a v0.3.x (#10 ) and will work on a tokio-proto replacement in a v0.4.x release.
Until then you might use a custom wrapper with a timeout feature.

@flosse flosse added this to the v0.4.0 milestone Feb 28, 2019
@flosse flosse mentioned this issue Feb 4, 2020
8 tasks
@flosse flosse modified the milestones: v0.4.0, v0.4.1 Mar 7, 2020
@MightyPork
Copy link
Contributor

any progress / plans for this?

it made me ditch the sync client and write this async abomination instead (my first time using futures, too)

let mut rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
        let mut ctx = tokio::time::timeout(Duration::from_secs(3),
                                           tokio_modbus::client::tcp::connect_slave(socket_addr, Slave(12)))
            .await.unwrap().unwrap();

        // more stuff
    });

@flosse flosse added the tcp label May 19, 2020
@glennpierce
Copy link

any progress / plans for this?

it made me ditch the sync client and write this async abomination instead (my first time using futures, too)

let mut rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
        let mut ctx = tokio::time::timeout(Duration::from_secs(3),
                                           tokio_modbus::client::tcp::connect_slave(socket_addr, Slave(12)))
            .await.unwrap().unwrap();

        // more stuff
    });

This saved me. Ugly but works

@flosse flosse removed this from the v0.4.1 milestone Jul 28, 2021
@flosse
Copy link
Member

flosse commented Sep 12, 2024

I consider the issue to be resolved.
Feel free to open it again if it is not.

@flosse flosse closed this as completed Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants