![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/userdefault.png)
09/19/2019
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
Hello,
to quickly read from and write data to an OPC UA server (which is out of my control) I'm currently using structured values instead of single Nodes. The serialization and deserialization of the data is handled in my C# code.
Writing an ExtensionObject with the exact same size as the value on the server works fine.
My problem are ExtensionObjects with a different size be it smaller or larger as on the server. The write requests come back with the "BadEndOfStream" status code.
Is there something I need to do to tell the write request that an object with different size will be sent?
This could also very likely be an issue with the server implementation, as of now I haven't confirmed that and debugging/stepping through the OPC UA Reference source code did not help very much.
Any help/advice would be very appreciated.
Have a great day!
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/userdefault.png)
09/19/2019
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
When I read the ExtensionObject and deserialize the byte array everything works as expected. To check if the serialization works I serialized the data I got from the ExtensionObject and get the exact same byte array. I'm assuming the serialization works because writing this ExtensionObject with the same size works and the write request goes through with status code "Good".
I am dynamically serializing C# objects into their byte array representation so I can send them to a PLC rather quickly instead registering and configuring multiple nodes.
The only problematic variables are strings because they vary in length. This is why my ExtensionObjects have different sizes.
Serialization for objects without strings works in both ways as expected.
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/admindefault.png)
05/30/2017
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
If you are using the built in BinaryEncoder to do the serialization then it is likely a bug in the server.
If you are using your own code to do the encoding then you may be putting the wrong bytes on the wire.
Using your code to decode what your code writes does not show that the encoding on the wire is correct.
The error sounds like a length in the stream is not being encoding correctly.
1 Guest(s)