简体   繁体   中英

Rust: MissingOrMalformedExtensions while connecting to Nats

I want to connect to the Nats server using Rust. To do this I tried to use crate async_nats . That's the documentation .

And here's my code:

use futures::StreamExt;

#[tokio::main]
async fn main() -> Result<(), async_nats::Error> {
    let client = async_nats::connect("nats://127.0.0.1:4222").await?;
    // let client = async_nats::connect("127.0.0.1:4222").await?;
    // let client = async_nats::connect("127.0.0.1").await?;
    let mut subscriber = client.subscribe("messages".into()).await?.take(10);

    for _ in 0..10 {
        client.publish("messages".into(), "data".into()).await?;
    }

    while let Some(message) = subscriber.next().await {
        println!("Received message {:?}", message);
    }

    Ok(())
}

It looks very similar to the example but it doesn't work. Rust panics with the message

Error: Custom { kind: Other, error: "failed to read root certificates: MissingOrMalformedExtensions" }
error: process didn't exit successfully: `target\debug\program.exe` (exit code: 1)

I thought the address might be a problem, so I tried a few variants, but it didn't help.

Could you please tell me what to do to eliminate this panic?

This has been fixed in

https://github.com/nats-io/nats.rs/pull/788

And will be part of next release.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM