awcullen / opcua

OPC Unified Architecture (OPC UA) in Go.
MIT License
81 stars 18 forks source link

Possibility to modify defaultMaxMessageSize #30

Closed FranckEtienne closed 1 year ago

FranckEtienne commented 1 year ago

We use your SDK to construct a client which must read a ByteString of 27Mb.

The server use Unified Automation SDK. We construct this server and we modify it to support ByteString of 32M.

We can read ByteString of 27Mb on server but I must modify defaultMaxMessageSize in pkg/mod/github.com/awcullen/opcua@v1.2.0/client/client_secure_channel.go : defaultMaxMessageSize

Is it possible to set a parameter to modify by software defaultMaxMessageSize ?

FranckEtienne commented 1 year ago

I modify defaultMaxMessageSize from 16Mb to 32 Mb.

Where is define this value of 16Mb for defaultMaxMessageSize ?

awcullen commented 1 year ago

I define it on line 50 of client_secure_channel.go

// defaultMaxMessageSize is the default limit on the size of messages that may be accepted.
defaultMaxMessageSize uint32 = 16 * 1024 * 1024

I shall add a new client option like WithMaxMessageSize() It's a good idea, thanks.

awcullen commented 1 year ago

Tag v1.2.2 added client option: // WithTransportLimits sets the limits on the size of the buffers and messages. (default: 64Kb, 64Mb, 4096) func WithTransportLimits(maxBufferSize, maxMessageSize, maxChunkCount uint32) Option

Changed DefaultMaxMessageSize to 64Mb.

Fixed MaxRequestMessageSize to limit the size of request from client. If exceeded, stack returns BadRequestTooLarge to caller.

Fixed MaxResponseMessageSize to limit the size of response from the server. If exceeded, stack returns BadResponseTooLarge to caller.