gopcua / opcua

Native Go OPC-UA library
MIT License
829 stars 253 forks source link

Error writing ByteString array (readChunk EOF) #695

Open jackchenjc opened 8 months ago

jackchenjc commented 8 months ago

Hi all,

I was trying to write a ByteString array value. Tweaked the examples/write demo and tested with ProSys simulation server:

diff --git a/examples/write/write.go b/examples/write/write.go
--- a/examples/write/write.go
+++ b/examples/write/write.go
@@ -18,7 +18,7 @@
        var (
                endpoint = flag.String("endpoint", "opc.tcp://localhost:4840", "OPC UA Endpoint URL")
                nodeID   = flag.String("node", "", "NodeID to read")
-               value    = flag.String("value", "", "value")
        )
        flag.BoolVar(&debug.Enable, "debug", false, "enable debug logging")
        flag.Parse()
@@ -40,7 +40,7 @@
                log.Fatalf("invalid node id: %v", err)
        }

-       v, err := ua.NewVariant(*value)
+       v, err := ua.NewVariant([][]byte{{'1', '2', '3'}, {'4', '5', '6'}})
        if err != nil {
                log.Fatalf("invalid value: %v", err)
        }

Screenshot 2023-10-27 at 1 48 14 PM

I then got the readChunk EOF error and the connection was disconnected and reconnecting again. Below are parts of the debug logs:

debug: uasc 2/6: send *ua.ReadRequest with 146 bytes
debug: uacp 2: recv MSGF with 64 bytes
debug: uasc 2/6: recv MSGF with 64 bytes
debug: uasc 2/6: recv *ua.ReadResponse
debug: uasc 2/6: sending *ua.ReadResponse to handler
debug: uasc 2/7: send *ua.ReadRequest with 131 bytes
debug: uacp 2: recv MSGF with 492 bytes
debug: uasc 2/7: recv MSGF with 492 bytes
debug: uasc 2/7: recv *ua.ReadResponse
debug: uasc 2/7: sending *ua.ReadResponse to handler
debug: uasc 2/8: send *ua.WriteRequest with 134 bytes
debug: uacp 2: recv ERRF with 81 bytes
debug: uasc 2: readChunk EOF
debug: client: monitor: disconnected
debug: client: monitor: auto-reconnecting
debug: client: monitor: action: createSecureChannel
debug: uacp 2: close
debug: sub: pause: pause
debug: uasc 2: Close()
debug: client: monitor: trying to recreate secure channel

Any help would be appreciated.