Skip to content

Cannot stop the server #142

@zvolin

Description

@zvolin

Hey, as in issue title. I wanted to test that a service gracefully handles networking issues like server being temporarily unreachable and wanted to do that by dropping the MockServer, however this loop actually never finishes:

use std::time::Duration;

use tokio::{net::TcpStream, time::sleep};
use wiremock::MockServer;

#[tokio::main]
async fn main() {
    let server = MockServer::start().await;
    let addr = *server.address();

    drop(server);

    loop {
        if TcpStream::connect(addr).await.is_err() {
            break;
        }
        sleep(Duration::from_millis(200)).await;
        println!("retrying");
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions