convertersystems / opc-ua-client

Visualize and control your enterprise using OPC Unified Architecture (OPC UA) and Visual Studio.
MIT License
402 stars 119 forks source link

Decoding halted because of invalid data in the stream. #59

Closed balamcsd closed 6 years ago

balamcsd commented 6 years ago

Hai, I am using Workstation.UaClient 2.0 when i try to connect to opc.tcp://My-PC:53530/OPCUA/SimulationServer i am able to successfully connect to prosys OPC UA simulation server. But when i try to create subscription
In this line BrowseResponse browseResponse = await channel.BrowseAsync(browseRequest); it throw exception Decoding halted because of invalid data in the stream. Same code works with kepserver. Please help to fix this issue Thanks

awcullen commented 6 years ago

Thank you for reporting this issue. I am using version 2.1.1 of Workstation.UaClient and version 2.2.2-109 of Prosys Simulation Server. I have tested browsing to three levels using the following code and have not found the exception. Please let me know if there was a particular NodeId you were browsing when the error occurred.

BR, Andrew

                Console.WriteLine("Step 4 - Browse the server namespace.");
                Console.WriteLine("+ Root");
                BrowseRequest browseRequest = new BrowseRequest
                {
                    NodesToBrowse = new BrowseDescription[] { new BrowseDescription { NodeId = NodeId.Parse(ObjectIds.RootFolder), BrowseDirection = BrowseDirection.Forward, ReferenceTypeId = NodeId.Parse(ReferenceTypeIds.HierarchicalReferences), NodeClassMask = (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method, IncludeSubtypes = true, ResultMask = (uint)BrowseResultMask.All } },
                };
                BrowseResponse browseResponse = await channel.BrowseAsync(browseRequest);
                foreach (var rd1 in browseResponse.Results[0].References ?? new ReferenceDescription[0])
                {
                    Console.WriteLine("  + {0}: {1}, {2}", rd1.DisplayName, rd1.BrowseName, rd1.NodeClass);
                    browseRequest = new BrowseRequest
                    {
                        NodesToBrowse = new BrowseDescription[] { new BrowseDescription { NodeId = ExpandedNodeId.ToNodeId(rd1.NodeId, channel.NamespaceUris), BrowseDirection = BrowseDirection.Forward, ReferenceTypeId = NodeId.Parse(ReferenceTypeIds.HierarchicalReferences), NodeClassMask = (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method, IncludeSubtypes = true, ResultMask = (uint)BrowseResultMask.All } },
                    };
                    browseResponse = await channel.BrowseAsync(browseRequest);
                    foreach (var rd2 in browseResponse.Results[0].References ?? new ReferenceDescription[0])
                    {
                        Console.WriteLine("    + {0}: {1}, {2}", rd2.DisplayName, rd2.BrowseName, rd2.NodeClass);
                        browseRequest = new BrowseRequest
                        {
                            NodesToBrowse = new BrowseDescription[] { new BrowseDescription { NodeId = ExpandedNodeId.ToNodeId(rd2.NodeId, channel.NamespaceUris), BrowseDirection = BrowseDirection.Forward, ReferenceTypeId = NodeId.Parse(ReferenceTypeIds.HierarchicalReferences), NodeClassMask = (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method, IncludeSubtypes = true, ResultMask = (uint)BrowseResultMask.All } },
                        };
                        browseResponse = await channel.BrowseAsync(browseRequest);
                        foreach (var rd3 in browseResponse.Results[0].References ?? new ReferenceDescription[0])
                        {
                            Console.WriteLine("      + {0}: {1}, {2}", rd3.DisplayName, rd3.BrowseName, rd3.NodeClass);
                        }
                    }
                }
balamcsd commented 6 years ago

If i use version 2.1.1 of Workstation.UaClient the problem will be resolved? Pros sys product version - v2.3.2-146 Thanks

awcullen commented 6 years ago

I successfully browsed all 2396 nodes using version 2.1.1 Let us know if you have success too.

balamcsd commented 6 years ago

What is Target framework?

awcullen commented 6 years ago

.net framework 4.6.1

Andrew Cullen 914-374-5275


From: balamcsd notifications@github.com Sent: Monday, February 19, 2018 11:10:47 PM To: convertersystems/opc-ua-client Cc: Andrew Cullen; Comment Subject: Re: [convertersystems/opc-ua-client] Decoding halted because of invalid data in the stream. (#59)

What is Target framework?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/convertersystems/opc-ua-client/issues/59#issuecomment-366861921, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALWWmjet68oNQ4ZJ7hewT_zx7KZLICosks5tWkXHgaJpZM4SKh6e.

balamcsd commented 6 years ago

Thanks. I changed my framework from 4.5.2 -> 4.6.1 and able to build the projects and create setup. But when i try to execute await channel.OpenAsync(); It throws "Could not load file or assembly 'System.Net.Sockets, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.":"System.Net.Sockets, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"} Please suggest Thanks

balamcsd commented 6 years ago

Yes, after upgrading Workstation.UaClient 2.1.1 it is working in both prosys and kepware Thanks

awcullen commented 6 years ago

Fantastic!