nauful / LibUA

Open-source OPC UA client and server library
Apache License 2.0
262 stars 94 forks source link

Unable to connect if client sends MaxMessageSize=0 in Hello #64

Closed heppth closed 3 years ago

heppth commented 3 years ago

Hello,

First of all, compliments for the library. It is fun to work with. I have detected a small issue. My OPC-UA client can not connect. The server has following output:

[Error] Sent TL error 0x80080000

My client sends MaxMessageSize=0, which indicates that the Client has no limit. The LibUA server then creates a MemoryBuffer with size 0.

Setting MaxMessageSize to zero is valid. See specification

My client also sends MaxChunkCount=0. I'm not sure if that leads to an other issue.

amsico commented 3 years ago

I had a similar problem when using another library which uses MaxMessageSize=0 as described above.

To solve the issue, I modified the Client.cs in line 980 by adding:

[...]
if (!recvHandler.RecvBuf.Decode(out config.TL.RemoteConfig.MaxChunkCount)) { return StatusCode.BadDecodingError; }

if (config.TL.RemoteConfig.MaxMessageSize > 0)
    MaximumMessageSize = (int)Math.Min(config.TL.RemoteConfig.MaxMessageSize, MaximumMessageSize);
nauful commented 3 years ago

Thanks, fixed.

krosthw commented 1 month ago

Hello, has been this if implemented? I don't see it in Client.cs. I have the same problem of @amsico.