Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to write empty string to value: StatusBad(0x80000000) #748

Open
jacobfrantz1 opened this issue Nov 4, 2024 · 1 comment
Open

Comments

@jacobfrantz1
Copy link

I'm currently using this package in production with several machines that have the "Siemens Sinumerik One" control w/ opcua server.

I ran into the issue that attempting to write an empty string to a node with a string value results in a StatusBad(0x80000000).

After some debugging, I found that for empty strings, the client sends a null value for the length of the string in the following lines: https://github.com/gopcua/opcua/blob/708f669296f58deba4d100507115e02166c0f0f9/ua/buffer.go#L273C1-L280C1. I've got my application working with a fork that writes a zero to the string length instead of the null value for empty strings.

My question is: is this package working as intended, and the servers I'm using are at fault, or is this a problem, and it isn't possible to write an empty string with the package as is.

@magiconair
Copy link
Member

Good point. We don't have any problem with this and we have a couple of thousand deployments on both Siemens and Beckhoff PLCs. @kung-foo also doesn't seem to have a problem with this. So I don't expect this to be a wide spread problem.

However, you are correct that there is the distinction between null and empty which OPC/UA allows and gopcua treats them both as null. (https://reference.opcfoundation.org/Core/Part6/v104/docs/5.2.2.4)

The challenge is that both server and client language have to cooperate since both can support either both or only one of them. If the string node isn't nullable you can't write a NULL string. If your programming language doesn't support null strings you have to pick one encoding. I think that's why I chose null strings at the time.

You can write your own Encode and Decode method for your struct. Check ua/datatypes.go for examples. It looks like WriteByteString does what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants