BadWriteNotSupported

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

Moderator: uasdknet

Post Reply
martenbyebye
Hero Member
Hero Member
Posts: 21
Joined: 03 Mar 2017, 16:08

BadWriteNotSupported

Post by martenbyebye »

Hi

I am able to write on myNode using the UaExpert, but not using my test code, so I am assuming that this client side code is wrong:

Code: Select all

            var nodesToWrite = new List<WriteValue>
                {
                    new WriteValue()
                        {
                            NodeId = myNodeId,
                            AttributeId = Attributes.Value,
                            Value = new DataValue(new Variant(new DateTime(2000, 01, 01)), DateTime.UtcNow) {ServerTimestamp = DateTime.UtcNow}
                        },                   
                };

            List<StatusCode> results = this.session.Write(
                nodesToWrite,
                new RequestSettings() { OperationTimeout = 10000 });

            foreach (var statusCode in results)
            {
                statusCode.ShouldBe(StatusCodes.Good);
            }
The returned statusCode is BadWriteNotSupported. The doc says
(http://documentation.unified-automation ... 5539e4546b)
"The server does not support writing the combination of value, status and timestamps provided.", but I am not able to understand what the problem is.

I saw this other post but it did not solve my problem. https://forum.unified-automation.com/po ... rted#p1481

I tried not giving the ServerTimeStamp and/or not giving the SourceTimeStamp, but nothing works. Am I giving the value in a wrong manner? And which status is the doc talking about? Should the StatusCode not be something that the server is setting, not the client?

I am not specifiying UserData in the code above. Does that leave the existing UserData on that node as it was, or will it overwrite it with null?

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

Re: BadWriteNotSupported

Post by Support Team »

Hello martenbyebye,

when writing an Attribute you need to pass in a DataValue. A DataValue consists of Value, StatusCode, SourceTimestamp, ServerTimestamp.
Most OPC UA server don't allow client to write StatusCode and/or Timestamp. So the client can just set the Value part of the DataValue.

Using this syntax will not set the ServerTimestamp:

Code: Select all

    nodesToWrite.Add(new WriteValue()
    {
        NodeId = writeValInfo.NodeId,
        Value = new DataValue()
        { WrappedValue = new Variant(DateTime.UtcNow) },
        AttributeId = Attributes.Value
    });
Also see here:
http://documentation.unified-automation ... bf5b9a177d
Best regards
Unified Automation Support Team

martenbyebye
Hero Member
Hero Member
Posts: 21
Joined: 03 Mar 2017, 16:08

Re: BadWriteNotSupported

Post by martenbyebye »

Ahhh. I understood from the other forum entry that the problem was NOT setting those times, but the problem was setting it....

It works now, thanks!

MrIS
Full Member
Full Member
Posts: 7
Joined: 19 Jul 2018, 10:30

Re: BadWriteNotSupported

Post by MrIS »

Hello,

what can I do in case if I run method Write and it ends with the exception The operation is not available because the session is in the 'Disconnected' state.? Do you have any hints what can be wrong? Server session seems to be fine. Thanks.

Post Reply