locka99 / opcua

A client and server implementation of the OPC UA specification written in Rust
Mozilla Public License 2.0
480 stars 129 forks source link

Help with understanding SequenceNumbers #141

Closed thosaa closed 2 years ago

thosaa commented 2 years ago

When I try to connect to a PLC using the client crate, I get this message back:

2021-11-01 12:38:49.209Z DEBUG opcua_client::message_queue - Request 1 was processed by the server

2021-11-01 12:38:49.213Z DEBUG opcua_client::message_queue - Response to Request 0 has been stored

2021-11-01 12:38:49.213Z ERROR opcua_client::message_queue - A response with request handle 0 doesn't belong to any request and will be ignored, inflight requests = {1: Some(SyncSender { .. })}, request = OpenSecureChannelResponse(OpenSecureChannelResponse { response_header: ResponseHeader { timestamp: DateTime { date_time: 1601-01-01T00:00:00Z }, request_handle: 0, service_result: HISTORICAL_RAW | Good, service_diagnostics: DiagnosticInfo { symbolic_id: None, namespace_uri: None, locale: None, localized_text: None, additional_info: None, inner_status_code: None, inner_diagnostic_info: None }, string_table: None, additional_header: ExtensionObject { node_id: NodeId { namespace: 0, identifier: Numeric(0) }, body: None } }, server_protocol_version: 0, security_token: ChannelSecurityToken { channel_id: 11, token_id: 1, created_at: DateTime { date_time: 2021-11-01T12:38:47.273Z }, revised_lifetime: 60000 }, server_nonce: ByteString { value: Some([]) } })

2021-11-01 12:38:59.209Z INFO  opcua_client::session::session_state - Timeout waiting for response from server

So a response is received, but not mapped to the request, I think.

Looking at the TCP packages it seems that we (the client crate) sends a request with SequenceNumber = 1: image

The server, however, sends a response with SequenceNumber = 652? image

I have tried to read the https://reference.opcfoundation.org/v104/Core/docs/Part6/6.7.2/#6.7.2.4 a couple of times, but I'm a confused over the "Gaps are permitted..." part. I think it only applies to a reconnect and not a connect.

Am I totally off?

thosaa commented 2 years ago

It might be related to the server not supporting any security modes... But still the different SequnceNumber is odd.

thosaa commented 2 years ago

The server ran version 1.02, which could be the reason.