-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plc4j-driver-opcua: Await writeAndFlush(msg) & send next msg async
All OPC-UA messages contain a sequence number, which is independent from the normal TCP sequence numbers. This sequence number is checked by the server, that may refuse to respond, if the sequence number is lower than the last received message's. Packetization itself happens asynchronously in netty, some time after `writeAndFlush(msg)` has been invoked by the application code. If there are concurrent calls to this function, there is no guarantee that messages are packeted in the same order as they have been added to `writeAndFlush(msg)`. This, in some cases, can cause OPC-UA messages being delivered to the server in different order, than it is specified by their sequence numbers, and the server may drop these messages, and the client eventually times out. As TCP guarantees delivering packets in the correct order, a trival solution is to simply wait for packetization to complete, before adding the next message to the pipeline. But yet comes a design problem: OPC-UA response handlers were written in a way, that they may send new messages, while processing the response. These handlers are executed on the netty event loop thread, which is shared among all Netty I/O operations, such as receiving/sending messages. This essentially means, that if a response handler is currently being executed, you cannot start packetizing a new message, because that would require the response handler to finish, which is waiting for guess what, the packetization to complete. Solution to this is to execute response handlers asynchronously, so they don't occupy the Netty event handler thread. This commit also fixes the `OpcuaPlcDriverTest` flakyness, experienced after #1139 had been merged. See also: https://ci-builds.apache.org/job/PLC4X/job/PLC4X/job/develop/1695/
- Loading branch information
Showing
5 changed files
with
36 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters