Commit Graph
670 Commits
Author SHA1 Message Date
Marc Schier af04893a37 Fix degradation to sync calls in the SDK on main paths used. (#2316)
- make session create fully async incl. loading of the complex type system
2023-09-22 12:17:03 +02:00
Martin Regen 5af60ef6b6 Make async service call use awaitable, session open improvements (#2318)
- Improvements when many sessions need to be opened
- Introduce a OpenAsync version which usesmore async calls for session creation
- add async interfaces to cert validator 
- refactor lock of encodeable factory
- add a `EndAsync` property to WriteRequest to allow to await a service call
- add a `EndSendRequestAsync` method to allow implementation of awaitable service calls
2023-09-22 07:45:47 +02:00
Camille Guérin c75bf9be00 Removed extra unnecessary code and fixed use of userWriteMask (#2269)
- Removed extra unnecessary code in  CompareArray<T>
- Fixed userWriteMask in NodeState.cs
2023-08-25 14:48:28 +02:00
bhnaphade 4e6d58e1a4 Fix for 'BadTooManyOperations' in session.publish / 'BadServerHalted' when server is stopped. (#2277)
* Fixed status code when server is shutdown
* Add latest statuscodes from 1.05.03 to support new BadServerTooBusy error code
* added default throttle delay in case an unknown error is returned on a publish request service call
2023-08-22 20:02:39 +02:00
dependabot[bot] 7f864c1ef6 Bump Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (#2271)
Bumps [Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets](https://github.com/dotnet/aspnetcore) from 2.1.3 to 2.1.40.
- [Release notes](https://github.com/dotnet/aspnetcore/releases)
- [Changelog](https://github.com/dotnet/aspnetcore/blob/main/docs/ReleasePlanning.md)
- [Commits](https://github.com/dotnet/aspnetcore/commits)

---
updated-dependencies:
- dependency-name: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-18 10:48:39 +02:00
dependabot[bot] 5f82d1b3d3 Bump Microsoft.Extensions.Logging.Abstractions from 3.1.32 to 7.0.1 (#2233)
* Bump Microsoft.Extensions.Logging.Abstractions from 3.1.32 to 7.0.1

Bumps [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime) from 3.1.32 to 7.0.1.
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](https://github.com/dotnet/runtime/commits/v7.0.1)

---
updated-dependencies:
- dependency-name: Microsoft.Extensions.Logging.Abstractions
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update Opc.Ua.Core.csproj

* Update UA Server Controls.csproj

* Update UA Client Controls.csproj

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-14 08:34:11 +02:00
bhnaphade c7381cf9f7 '#' is not treated as a reserved character in RelativePath's text format (#2264)
* updated reserve char check in RelativePath
* updated logic and added tests
2023-08-12 07:44:04 +02:00
Suciu Mircea Adrian cb99f46599 Fixed NodeId.CompareTo() null reference exception (#2263)
* Fixed NodeId.CompareTo() null reference exception when InnerNodeId is null
* more test cases and guid compare as described
* special null NodeId check test case
2023-08-11 22:23:19 +02:00
Martin Regen 82ed6c8ca8 Refactor IEncoder/IDecoder to derive from IDisposable (#2254)
- Currently the `IEncoder`/`IDecoder` interface is not disposable, which makes it difficult to use the interfaces with `using`. Only the implementations are derived from `IDisposable`
- Change: Moved the `IDisposable` interface from implementations to the IEncoder/IDecoder
- To fully support the use of the interfaces across the codebase new methods are added: `Close` and `CloseAndReturnAsText`
- Breaking change: In the `XmlEncoder` the `Close` method which returns an encoded string is renamed to  `CloseAndReturnAsText`
- Refactor codebase to use `using` with IEncoder/IDecoder across the board. Use interfaces where possible.
- To support streaming better with `ArraySegmentStream`, derive this class from `MemoryStream` and implement `ToArray`
2023-08-11 11:56:47 +02:00
Martin Regen 0a51dd3d02 Complete ISessionFactory interface (#2255)
- A few use cases were still missing from the ISessionFactory interface to make the static `Session.Create` functions completely obsolete. 
- Follow naming conventions (Async) and add CancellationToken where missing.
2023-08-10 16:41:36 +02:00
Martin Regen 1e535dda09 Support client activities on all target platforms (#2256)
- Add the system diagnostics library for unsupported target platforms
- Integrate in clientfixture by adding IDisposable to support to enable/disable the activity tracing
- fix Traceable session dispose issue, do not null the disposed session
2023-08-10 09:48:36 +02:00
Martin Regen 81340c3473 Support for session reconnect from distributed clients (#2244)
- Support Client.Session API to save and restore session configuration information as xml or in a serializable data structure.
- Support to reactivate a session using a new secure channel. 
- API tests
2023-08-03 22:27:53 +02:00
Martin Regen e61664f586 Truncate inner diagnostics if nested depth too high (#2247)
- `DiagnosticInfo` contains the `InnerDiagnosticInfo` which can be nested. Limit the recursion to `MaxInnerDepth` in multiple places to prevent stack overflow / endless loops.
- The default value for MaxInnerDepth should not be more than 5.
2023-07-31 16:11:40 +02:00
Martin Regen 1f17aad109 Better NodeId/ExpandedNodeId built in types handling (#2230)
- A NodeId string can be assigned to a NodeId and is automatically parsed. However, if the string contains a "nsu=" it is considered a string type NodeId instead of decoding the namespaceUri. To avoid this error in the code an `ArgumentException` is thrown to uncover these coding errors. Such a variable needs to be an ExpandedNodeId to be decoded correctly.
- Breaking change: To reduce coding errors the user group decided to throw also on a constructor call which does not contain a nodeid type prefix and namespace index. e.g. `new NodeId("Testnode")`. If somebody wants a string NodeId in Namespace 0 then call the constructor `new NodeId("TestNode", 0)`
- Implement IEquatable<NodeId>/IEquatable<ExpandedNodeId>
- Tests to ensure .Distinct treats all Null NodeIds as identical.
- Unit tests for constructor behavior.
2023-07-28 14:38:37 +02:00
Martin Regen 04cd9bc66a Zip embedded Opc.Ua.NodeSet2.xml to reduce assembly size (#2232)
- Add only the zipped NodeSet2.xml as embedded resource
- Reduces assembly size by at least 2MB
- Breaking Change: Embedded resource Opc.Ua.NodeSet2.xml is now Opc.Ua.NodeSet2.xml.zip
2023-07-27 19:06:26 +02:00
Martin Regen 9256c2e0fe Improve ArraySegmentStream hotpath (#2241)
- Improve the encoding/decoding hotpath in the `ArraySegmentStream` by adding override for ReadByte/WriteByte and enforce inlining.
2023-07-27 19:05:13 +02:00
Marc Schier 7f851599a2 Always use ArrayPool.Shared for optimized use of buffers in buffer manager (#2224)
* The suggestion from .net team is to use shared pool if you have < 1mb buffers you need. 
* We now share buffers across connections which is far more efficient when many channels are created and closed.
2023-07-22 18:45:54 +02:00
Martin Regen c64eb53509 Fix corner cases of subscription transfer (#2227)
- With the `sequentialPublishing` flag enabled, no data is received after transfer. Fix: add a resync flag to update the last sequence counter after transfer.
- Instead of the semaphore slim use a dedicated Task per subscription. The task  is using `AsyncAutoResetEvent` to be task friendly, becasue every subscription gets a worker task.
- Add more tests for the use case republish with delayed ack.
- Add a test and a missing method to support reconnect of a session on a different secure channel without reconnect handler.
2023-07-21 13:10:00 +02:00
Martin Regen 0bf2e93d8c Add IJsonEncoder/IJsonDecoder interfaces (#2042)
- in order to abstract the implementation of a IEncoder/IDecoder  for Json with some extra methods and properties, derive JsonEncoder/Jsondecoder from a IJsonDecoder/IJsonEncoder interface
- breaking change: the use of reversible/non-reversible subencoding is handled by a new method:
`void UsingReversibleEncoding<T>(Action<string, T> action, string fieldName, T value, bool useReversibleEncoding)`
2023-07-20 15:37:54 +02:00
Suciu Mircea Adrian eaa3cb0af5 Bring back Microsoft.Extensions.Logging.Abstractions to V3.1.32 for older target frameworks (#2229) 2023-07-20 10:47:49 +03:00
dependabot[bot]andMartin Regen 5a08618af0 Bump Microsoft.Extensions.Logging.Abstractions from 3.1.32 to 7.0.1 (#2194)
* Bump Microsoft.Extensions.Logging.Abstractions from 3.1.32 to 7.0.1

Bumps [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime) from 3.1.32 to 7.0.1.
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](https://github.com/dotnet/runtime/commits/v7.0.1)

---
updated-dependencies:
- dependency-name: Microsoft.Extensions.Logging.Abstractions
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update Opc.Ua.Core.csproj

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Martin Regen <mregen@microsoft.com>
2023-07-19 10:33:07 +03:00
MarkusHorstmann 2738a2971c Support Dynamic Complex Types (#2146)
Complex Type support assumes that every OPC type is represented by exactly one .Net type, which in turn knows encoding ids, XML names etc.
These changes enable use of a single type that implements encoding/decoding based on OPC type information at runtime.
2023-07-16 09:50:18 +02:00
Martin Regen 17d4f0475f Fix stringtables for diagnostic results when service calls are batched (#2222)
- Issue fix: Currently when diagnostics is enabled in client calls, the string table in the response header is not updated when a service call is split into multiple service calls.  In this case the stringtables from all calls must be appended and the index in the diagnosticinfo must be updated to match the updated string list.
- To reduce the number of 'null' DiagnosticInfo allocations, the decoders now try to return null instead of a default DiagnosticInfo. A new property ÌsNullDiagnosticInfo' can be used to check for unused DiagnosticInfo entries.
- The tests were slightly improved to use test set data from the generated TestData namespace, which contains also a historical node.
- All `ServerFixtureUtils.ValidateXXX` checks were updated to include the check for diagnosticInfos and the string tables to catch issues.
2023-07-13 19:18:24 +02:00
Martin Regen cd38eca781 Various bugfixes for CTT and others (#2212)
- SessionClientBatched doesn't handle the case when diagnosticinfos are requested and the batched calls returns mixed empty or non empty diagnostic infos, then the returned infos did not match the number of requested items.
- write of arrays of analogItemState are not properly checked
- BuildInfo properties were empty because BuildInfoVariableValue is never initialized
- DataType and ReferenceType may return null attributes instead of BadAttributeIdInvalid.
- Add BuildInfo test and fix the NodeCacheTest
2023-07-04 16:44:06 +02:00
Martin Regen 49c85322bd Fix build on merged commits 2023-06-27 17:07:51 +02:00
Martin Regen ae00175fe8 Merge branch 'master' into master371_temp 2023-06-27 10:01:34 +02:00
Martin Regen 010a839ee8 Support custom cert store with flat directory structure (#2198)
In some use cases (e.g. Kubernetes secrets) it would be beneficial to store the certificates, private keys, crl etc. in a flat directory instead of having a root which contains a hierarchy with certs/crl/private etc. 
- Modify the `DirectoryCertificateStore` to allow it to use a flat structure by adding a special constructor.
- Add the configuration builder functions to allow to specify custom certificate stores for app/user/https.
- Add a test sample which shows how to use the 'flat store' with a custom cert store wrapper.
- By default, behavior of `DirectoryCertificateStore` is unchanged. Needs an external wrapper to expose the flat mode.
2023-06-22 16:31:21 +02:00
Suciu Mircea Adrian c81b6b0103 Added newly modified model compiler generated code for v1.04 (#2195)
Update the model compiler generated files with latest modifications which fix the embedded initializers of the generated classes.
2023-06-20 07:05:30 +03:00
Martin Regen e89b06e57b Add metadata to fast data and event callbacks notification. (#2176)
- if `DisableMonitoredItemCache` is set, the sequencenumber and publish time are unavailable. Add helpers to NotificationData to get the information in the fast data and event callbacks.
- new fast callback for keep alive messages
2023-06-14 09:47:21 +02:00
Martin Regen c7bd19dc46 Support use of opc.https endpoint url for client and server. (#2140)
Currently the https protocol doesn't support a spec compliant endpoint with a `opc.https` prefix., as client and server.
Fix:
- Add the client and server support for the `opc.https` prefix. 
- Continue support for `https` prefix for non compliant implementations.
- Any CancellationTokenSource should be disposed after being used.
- Follow coding guidelines
- Use macOS cert callback
2023-06-12 09:05:10 +02:00
Martin Regen 043a56c3f2 Deprecate .NET framework 4.6.2 support, sync with samples repo (#2165)
- Deprecate support for Nuget package support of .NET Framework 4.6.2
- Bump sample applications to 4.8
- update some copyright headers / supporting files (editorconfig etc.)
- fix a few warnings
- fix an issue with `SessionReconnectHandler`, in certain combination of reconnect period and exponential backoff the .NET sample app never reconnected.
2023-05-31 18:53:56 +02:00
Martin Regen d8f8a4e7ad Merge pull request #2163 from OPCFoundation/master371
Merge release 1.4.371.91 in master
2023-05-27 05:52:47 +02:00
Martin RegenandMarkus Horstmann 0a3546a3bf JsonDecoder: ReadExtensionObject returns partial JSON for some types (#2155)
Cherry pick bugfix from #2146:
ReadExtensionObject returns partial JSON for some types.
It appears that this is due to the JSON being read before the JsonTextWriter is closed.

see also: 2a4ba56

Co-authored-by: Markus Horstmann <markushorstmann@hotmail.com>
2023-05-19 15:20:53 +02:00
Martin Regen c13bb0e600 Fix possible memory leak of CancellationTokenSource (#2156)
Fix a few cases (not all) where TCS are not properly disposed. Specifically BeginConnect, which may cause resource leaks.
2023-05-19 15:19:04 +02:00
Suciu Mircea Adrian 24ba1d5db4 Allow initiation of reverse connections from all endpoints of the server. (#2152)
Currently only the first endpoint of the server will initiate a reverse connection, resulting in the possibility to connect only to it. This change enables connection to all the server's endpoints via reverse connect.
2023-05-19 08:41:56 +02:00
MarkusHorstmann 29a3be5533 Json Encoder: namespace URI handling (#2119)
Changes to the JSON Encoder to make it easier to deal with namespace URIs.
* #2117: JSON Encoder should provide option to encode NamespaceUri for all namespaces, including index 1
* #2118: JSON Encoder does not honor ForceNamespaceUri for QualifiedNames
2023-04-28 09:19:20 +02:00
Martin Regen 24845eb69d Use ICloneable in generated code (#2044)
- ICloneable was removed from generated code for the first port to .NET Standard 1.x, instead MemberwiseClone was used
- Reenable ICloneable for generated code
- Add ICloneable to built in types
- Fix code where MemberwiseClone is called instead of Clone
2023-04-27 11:08:13 +02:00
Suciu Mircea Adrian ae7f8e5120 OnServerStarting - Add null check on validationErrors (#2128) 2023-04-21 12:42:47 +03:00
Martin Regen 04721cb144 Return AdditionalInfo only to users with permission. (#2124)
- Add permission validation if client requests DiagnosticInfo.
2023-04-18 23:14:53 +02:00
Martin Regen abfbde3bec Improvements for docker hosting and fix for GetEndpoints (#2123)
- Add environment variables as parameter to support docker hosting where command line parameter are not available
- bump some Nuget packages
- only warn on cert validation error on startup, e.g. when the CRL becomes outdated allow to start and print warning.
- Let GetEndpoints return endpoints which match the DNS name used. DNS names must be specified as alternate hostnames in the configuration.
2023-04-18 18:09:55 +02:00
Martin Regen b5d4dd79cf Check DiscoveryOnly before the message is parsed. (#2112)
A discovery only channel only accepts discovery service calls. The type of service call should be checked before the message is parsed. 
- Add a check for discovery message before the chunks are decoded.
- Add a check that discovery service call are below a restricted message size (e.g. 64k).
- Add a test case.
2023-04-11 08:20:28 +02:00
Martin Regenandmrsuciu 67fd91ca99 Close socket if a client stops processing responses. (#2110)
- If a client stops receiving data from a server, stop reading from the client channel and close the socket after a timeout if the client can not recover to force a reconnection.  
- simplify buffer manager, ArrayPool is already thread safe, additional locks can be removed

Co-authored-by: mrsuciu <Mircea-Adrian.Suciu@softing.com>
2023-04-10 20:49:02 +02:00
Martin Regen d65e1cfc27 Fixes to support structures with allowsubtypes (#2104)
Fixes an issue found with a server with an address model that implements structures with abstract complex types and with structures which allow subtypes. The client could hang endless when building the complex type system in this case.
The StructureFieldAttribute has the wrong AttributeTypeIds set.
2023-03-27 23:09:24 +02:00
dependabot[bot] bd0f02ab2a Bump Newtonsoft.Json from 13.0.2 to 13.0.3 (#2100)
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 13.0.2 to 13.0.3.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/13.0.2...13.0.3)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-20 19:36:05 -05:00
Martin Regen 241583def4 Add structure to Quickstart server TestData (#2008)
- Rebuild designs with latest ModelCompiler (docker)
- Add the scalar value datatype as structure with properties
- Uses update to Modelcompiler: https://github.com/mregen/UA-ModelCompiler/tree/structures2
2023-03-17 10:44:50 -07:00
Martin Regen b35d9c1113 Improve hashcode calculation for some built in types (#2082)
- Problem to be solved: Currently using dictionaries of NodeId or ExpandedNodeId may not work correctly due to the homebrew hash code generation, which may cause false duplicates.
- Use the HashCode library to calculate the hashcodes for some BuiltInTypes, mostly NodeId/ExpandedNodeId.
- Fix an issue with csproj where VS 2019 did not show errors
- Update copyright year
2023-02-27 14:55:36 +01:00
Martin Regen 8d18e3304a Default SendCertficateChain=true and temp fix for BuildInfo (#2064)
- After discussion default SendCertChain to true
- Bring back part of the code which was removed by Modelcompiler to fix the BuildStatus variable
- Fix the GDS Server Push, which does not fully update the server descriptions with a chain, if sendcertchain is selected
- fix issue in macOS, when cert chains are used the X509Certificate2 constructor throws exception
2023-02-20 12:08:39 +01:00
Martin Regen 53fa0bd4bd Do not dispose BinaryEncoder stream if leaveOpen is set (#2053)
* Do not dispose the stream if the BinaryEncoder leaveopen flag is set in the constructor + ported tests from JSON
2023-01-24 09:36:21 +00:00
Marc Schier 65f9757b91 Add an API to ComplexTypeSystem to retrieve data type definitions used during loading (#2039)
The changes add an API to ComplexTypeSystem to retrieve data type definitions that were created during type building to leverage them to build DataSetMetaDataType for OPC UA PubSub.  

The changes include the following:

* Combine all conversion of enumerations into EnumDefinition and use the resulting to build the type
* Remove all other API from the type builder interface and implementation. 
  > The assumption is that these interfaces are used internally and removal will not cause a breaking change.
* Combine everything previously covered elsewhere into existing AddEnumType function.
* Add a NodeIdDictionary cache and fill that cache during load, as well as API to retrieve the data type definitions
2023-01-09 16:08:06 +01:00
dependabot[bot]andMartin Regen 7c0ba9429c Bump Moq, Nunit.Console and BenchmarkDotNet (#2034)
* Bump BenchmarkDotNet from 0.13.2 to 0.13.3
* Bump Moq from 4.18.3 to 4.18.4
* Bump NUnit.Console from 3.16.0 to 3.16.1
* fix a typo
* fix docker tag version

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Martin Regen <mregen@microsoft.com>
2023-01-06 21:01:30 +01:00