OpcUaClient.FileModel Write

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
Sleepy-Simon89
Jr. Member
Jr. Member
Posts: 1
Joined: 18 May 2020, 15:17

OpcUaClient.FileModel Write

Post by Sleepy-Simon89 »

Hello,

I have implemented a short file transfer client example with .NET OPC UA SDK (code see below).

I create FileModel object and set the servers file node id. Then I split large file into chunks because the message size is limited to 16MB.
But on file.Write I get the following exception:
StatusException Message: "Write failed because the resulting size of the file would exceed the {0} byte limits set by the server."

What am I doing wrong? MaxFileSize on server side (FileModel) is set to 250 MB and my file is a lot smaller.

Code: Select all

public void WriteFile(NodeId fileNodeId, uint fileHandle, byte[] data)
        {
            FileModel file = new FileModel(session);
            file.FileNodeId = fileNodeId;
            // split on groups with each 15.000.000 items each
            byte[][] chunks = data
                                .Select((s, i) => new { Value = s, Index = i })
                                .GroupBy(x => x.Index / 15000000)
                                .Select(grp => grp.Select(x => x.Value).ToArray())
                                .ToArray();

            for (int i = 0; i < chunks.Length; i++)
            {
                file.Write(fileHandle, chunks[i], 0);
            }

            file.Close(fileHandle);
        }

User avatar
Support Team
Hero Member
Hero Member
Posts: 2649
Joined: 18 Mar 2011, 15:09

Re: OpcUaClient.FileModel Write

Post by Support Team »

Hello Simon,

your code example seems to work correctly.
Please check if the MaxFileSize of your file node is large enough.
Best regards
Unified Automation Support Team

Post Reply