OPC UA File Transfer internals: Difference between revisions

From OPC Labs Knowledge Base
Line 5: Line 5:


= Connection locking =
= Connection locking =
OPC UA file handles are only valid in scope of the OPC UA session. If the client disconnects from the servers and establishes a new session, the previously obtained file handle is no longer (guaranteed to be) valid. Since QuickOPC normally automatically disconnects from the server when the session is not needed, this could cause a problem if the file handle was needed over a longer time period. The file transfer implementation prevents this issue by locking the connection (forcing the session to stay open) until the file handle is disposed of.
OPC UA file handles are only valid in scope of the OPC UA session. If the client disconnects from the servers and establishes a new session, the previously obtained file handle is no longer (guaranteed to be) valid. Since QuickOPC normally automatically disconnects from the server when the session is not needed, this could cause a problem if the file handle was needed over a longer time period.  


Note that "forced" session terminations, such as those caused by long-lasting network disconnections, can still render the OPC UA file handle invalid, which will manifest itself by persistent errors returned from operations made with that handle.  
The file transfer implementation prevents this issue by locking the connection (forcing the session to stay open) until the file handle is disposed of.
 
Note that "forced" session terminations, such as those caused by long-lasting network disconnections, can still render the OPC UA file handle invalid, which will manifest itself by persistent errors returned from operations made with that handle.


= Stream buffering =
= Stream buffering =

Revision as of 08:39, 20 May 2021

This article describes certain internal aspects of OPC UA File Transfer implementation in QuickOPC.

Object type checking

Before performing the actual file transfer operation, QuickOPC libraries check whether the target object exists and is of the intended type (file or directory). Without this, some operations would not behave predictably and could return errors that do not describe the problem well.

Connection locking

OPC UA file handles are only valid in scope of the OPC UA session. If the client disconnects from the servers and establishes a new session, the previously obtained file handle is no longer (guaranteed to be) valid. Since QuickOPC normally automatically disconnects from the server when the session is not needed, this could cause a problem if the file handle was needed over a longer time period.

The file transfer implementation prevents this issue by locking the connection (forcing the session to stay open) until the file handle is disposed of.

Note that "forced" session terminations, such as those caused by long-lasting network disconnections, can still render the OPC UA file handle invalid, which will manifest itself by persistent errors returned from operations made with that handle.

Stream buffering

In OPC UA, it is important to prevent "chatty" communication: Operations should be grouped together and performed on larger bodies of data, if possible. This is because the communication between the client and the server can be (relatively) slow, and each service calls introduces its own time delay.

When OPC UA files are exposed as (.NET) streams, the developer is free to read any number of bytes from the stream, or write any number of bytes to the stream. It is not uncommon that the algorithm reads or writes small number of bytes many times in a sequence. This could lead to very poor performance with OPC UA, because every read or write requires a separate OPC UA service call. There is, however, nothing intrinsically wrong in accessing the stream in this way, and many algorithms with streams are abstract, written in such a way that they are not aware of the ramifications of the underlying technology.

In order to prevent performance degradation when stream data is accessed in small segments, QuickOPC (unless instructed otherwise) automatically buffers all operations on OPC UA streams in memory. The default buffer size is 4096 bytes (in version 2021.2).

Stream expansion

(tbd)

Read/write chunking

(tbd)

Metadata caching and model changes

(tbd)

Read/write size limits

(tbd)

Adaptive read/write sizes

(tbd)