简体   繁体   English

Rust:连接到 Nats 时出现 MissingOrMalformedExtensions

[英]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 .我想使用 Rust 连接到 Nats 服务器。为此,我尝试使用 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 Rust 消息引起恐慌

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 https://github.com/nats-io/nats.rs/pull/788

And will be part of next release.并将成为下一个版本的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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