This repository was archived by the owner on Jan 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
This repository was archived by the owner on Jan 17, 2020. It is now read-only.
TLS example doesn't work #181
Copy link
Copy link
Open
Description
Hello,
The tls example doesn't work for me, I tried the following code:
use rumqtt::{MqttClient, MqttOptions, QoS};
use std::{thread, time::Duration};
fn main() {
pretty_env_logger::init();
let client_id = "tls-test".to_owned();
let ca = include_bytes!("path/to/cert.pem").to_vec();
let client_cert = include_bytes!("path/to/client-cert.pem").to_vec();
let client_key = include_bytes!("path/to/client-key.pem").to_vec();
let mqtt_options = MqttOptions::new(client_id, "xxxxxxx", 8883)
.set_ca(ca)
.set_client_auth(client_cert, client_key)
.set_keep_alive(10);
MqttClient::start(mqtt_options);
// let topic = "hello/world";
// thread::spawn(move || {
// for i in 0..100 {
// let payload = format!("publish {}", i);
// thread::sleep(Duration::from_secs(1));
// if let Err(err) = mqtt_client.publish(topic.clone(), QoS::AtLeastOnce, false, payload) {
// println!("{:?}", err);
// }
// }
// });
// for notification in notifications {
// println!("{:?}", notification)
// }
}I got the following message while executing RUST_BACKTRACE=1 cargo run --example tls, is there any workaround or am I doing something wrong?
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ()', src/libcore/result.rs:1165:5
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:77
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:61
4: core::fmt::write
at src/libcore/fmt/mod.rs:1030
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1412
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:65
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:50
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:188
9: std::panicking::default_hook
at src/libstd/panicking.rs:205
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:464
11: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:373
12: rust_begin_unwind
at src/libstd/panicking.rs:302
13: core::panicking::panic_fmt
at src/libcore/panicking.rs:141
14: core::result::unwrap_failed
at src/libcore/result.rs:1165
15: core::result::Result<T,E>::unwrap
at /rustc/4f03f4a989d1c8346c19dfb417a77c09b34408b8/src/libcore/result.rs:933
16: rumqtt::client::network::stream::NetworkStreamBuilder::connect
at src/client/network.rs:208
17: rumqtt::client::connection::Connection::tcp_connect_future
at src/client/connection.rs:315
18: rumqtt::client::connection::Connection::mqtt_connect
at src/client/connection.rs:321
19: rumqtt::client::connection::Connection::mqtt_eventloop
at src/client/connection.rs:91
20: rumqtt::client::connection::Connection::run::{{closure}}
at src/client/connection.rs:60
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Metadata
Metadata
Assignees
Labels
No labels