takraj opened a new pull request, #1147: URL: https://github.com/apache/plc4x/pull/1147
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 https://github.com/apache/plc4x/pull/1139 had been merged. See also: https://ci-builds.apache.org/job/PLC4X/job/PLC4X/job/develop/1695/ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
