opcua: Failing to connect to server
Hello!
I am trying to evaluate this library, I started by trying the python client, which connects without much hassle. I was just trying out the samples found here: https://github.com/FreeOpcUa/python-opcua/blob/master/examples/client-minimal.py
I cannot however get this client to connect to the same server I am trying against. I am using this code:
fn main() {
let mut client = ClientBuilder::new()
.application_name("TestClient")
.application_uri("urn:TestClient")
.create_sample_keypair(false)
.trust_server_certs(true)
.session_retry_limit(3)
.client()
.unwrap();
println!("Clientbuilder");
// Create an endpoint. The EndpointDescription can be made from a tuple consisting of
// the endpoint url, security policy, message security mode and user token policy.
let endpoint: EndpointDescription = (
format!("{}:{}", OPC_IP, OPC_PORT).as_str(),
"None",
MessageSecurityMode::None,
UserTokenPolicy::anonymous(),
)
.into();
println!("Endpoint");
// Create the session
match client.connect_to_endpoint(endpoint, IdentityToken::Anonymous) {
Ok(session) => {
println!("Connected");
// Create a subscription and monitored items
if subscribe_to_values(session.clone()).is_ok() {
let _ = Session::run(session);
} else {
println!("Error creating subscription");
}
}
Err(e) => {
println!("{:?}", e);
}
}
println!("exit");
}
But I keep getting this error:
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/krille/.cargo/registry/src/github.com-1ecc6299db9ec823/opcua-client-0.7.0/src/message_queue.rs:49:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 16 (13 by maintainers)
@milgner It’s a B&R Automation server, not sure about the version.
Hmm … As I am writing this, I just discovered that if I run the code without a
#[tokio::main]
context, it works.Well, the output still looks suspicious, but it doesn’t crash anymore.