Client connect error:BadNonceInvalid
LongZoz opened this issue · 0 comments
LongZoz commented
I use the client created by opcua-master\samples\simple-client to connect to the local server (security model: None), the connection Got an error while creating the default session - BadNonceInvalid. Here is my code, just modifying the target url, the local server is Prosys opc ua simulation server
fn main() -> Result<(), ()> {
// Read command line arguments
let args = Args::parse_args().map_err(|_| Args::usage())?;
if args.help {
Args::usage();
} else {
// Optional - enable OPC UA logging
opcua::console_logging::init();
// Make the client configuration
let mut client = ClientBuilder::new()
.application_name("Simple Client")
.application_uri("urn:SimpleClient")
.product_uri("urn:SimpleClient")
.trust_server_certs(true)
.create_sample_keypair(true)
.session_retry_limit(3)
.client()
.unwrap();
println!("123");
if let Ok(session) = client.connect_to_endpoint(
(
// args.url.as_ref(),
"opc.tcp://Zwl:53530/OPCUA/SimulationServer",
SecurityPolicy::None.to_str(),
MessageSecurityMode::None,
UserTokenPolicy::anonymous(),
),
IdentityToken::Anonymous,
) {
println!("456");
if let Err(result) = subscribe_to_variables(session.clone(), 2) {
println!(
"ERROR: Got an error while subscribing to variables - {}",
result
);
} else {
// Loops forever. The publish thread will call the callback with changes on the variables
let _ = Session::run(session);
}
}
}
Ok(())
}