FreeOpcUa / freeopcua

Open Source C++ OPC-UA Server and Client Library
http://freeopcua.github.io/
GNU Lesser General Public License v3.0
712 stars 341 forks source link

Can't monitor large number variables in client, e.g. 1000 items #193

Open failihuang opened 8 years ago

failihuang commented 8 years ago

Hi I test opcua-server with the "example_server.cpp" and I add 1000 variables to the server. The code is as below. Node vars[1000]; for (i = 0; i < 1000; i++) { sprintf(varsname, "myvar%03d", i); vars[i] = newobject.AddVariable(idx, varsname, Variant(8)); }

When I add all the 1000 variables to the Data Access View of UaExpert client(a free opcua client) to monitor them, the server shows the error message as below.

_opc_tcp_async| Waiting for client connection at: 0.0.0.0:4841 expecting 4 received: 3 opc_tcpasync| Failed to process message. Not enough data was received from channel.

I enlarge the size of buffer in OpcTcpConnection::OpcTcpConnection() in which the default is 8192 And everything is OK.

Does it mean I should modify the size according the numbers of monitored items?

Thank you very much.

Magnulas commented 6 years ago

I've encountered this issue as well. The root cause seems to be that when messageSize is larger than the buffer size on line 213 in opc_tcp_async.cpp only a partial message will be stored in the buffer.

When the buffer is later read at line 51 in binary_serialization.h this will eventually lead to the error, since the size read at line 39 will make the for loop try and deserialize more data than is available in the buffer.