Commit Graph

1293 Commits

Author SHA1 Message Date
Martin Regen 33ae8bbec5 Set DefaultEncodingId in DataTypeDefinition, was always null NodeId (#1523)
- DefaultEncodingId is always set to binary encoding id. Helper added to StructureDefinition for other use cases (e.g. PubSub)
- the default encoding id is derived for the encodeable factory, since the typetree does not contain sufficent information to find the proper binary encoding id
- add a few helper functions in core for an upcoming PR that was used for testing with custom types, will simplify to add more nodemanagers to servers with custom types
2021-09-24 16:25:21 +02:00
Martin Regen 0d34b7d134 Test to validate client publish request count (#1516)
* add test to validate that too many BadTooManyPublishrequest do not cause message flooding
* improve the sequential publishing test to avoid the flaky tests
2021-09-21 16:06:51 +02:00
Cristian Pogacean 7d310d57bd Fix NodeSet import/export of ArrayDimensions in StructureField #1115 (#1517)
Fix NodeSet import/export of ArrayDimensions in StructureField #1115
2021-09-20 14:36:38 +02:00
Suciu Mircea Adrian 33cbddb49b Enable the coexistence of a Server and Client sessions in the same process, which consume custom data types. (#1514)
Called ServerBase::CreateMessageContext(true) to use a clone of EncodeableFactory.GlobalFactory
2021-09-20 11:56:14 +03:00
Cristian Pogacean 5048189195 fix bug - nodeset2 export of namespace index #689 (#1510)
* fix bug - nodeset2 export of namespace index #689

* the actual fix for #689
2021-09-16 22:30:29 +03:00
Elijah Burshtein 92ae1d324e Enable Subscription to invoke callbacks sequentially and synchronously (#1493)
Pertaining to the discussion started in Issue #957, this Pull Request seeks to add capabilities for Subscription to sequentially invoke its MonitoredItem and FastDataChange callbacks to maintain order properly. The key goal is to avoid out-of-order monitored items. To this effect, the Sequential Publishing capability is added to Subscription
Resolves #957 

### SequentialPublishing
A toggle which forces Subscription to raise callbacks only in a sequential order by the SequenceNumber of the incoming message. It limits the number of tasks that can process publish responses to 1, and enforces a strict +1 Sequence Number requirement before releasing a message.

#### Backwards compatibility
The new property has been added as DataMember at the end to maintain backwards compatibility with the DataContract, where such may be used. The relevant copy constructor has also been updated.

The feature is disabled by default, so the existing behavior is the default. Users must explicitly set the property on the Subscription object to enable these new features. 

#### Leveraging existing "time machine" in SaveMessageInCache
There is already a mechanism for re-ordering messages that entered in the wrong order. This change makes use of that existing "time machine" which sorts messages into chronological order (by the sequence number) to only pull off messages with a proper +1 sequence number each time.

#### KeepAlive messages advancing sequence number
KeepAlive messages do not contain notifications, and do not enter the proper branch in the code to be pulled out. They will not interrupt sequential flow. Since the next message in the sequence with data will "re-use" that sequence number, it can be expected to maintain sequence. 

#### Delayed messages
When sequential publishing is enabled, if a message is genuinely missing from the sequence, it will "hold up" the messages until it either arrives or is pulled out of the incoming messages list by being too old. In either case, it is considered "processed" for the sequence purposes at that point and the rest of the messages may proceed. 

The automatic republish request mechanism is also leveraged here for that purpose as well.

#### SequenceNumber roll-over after max value
As specified in the OPC UA spec, at 1ms publishing, this would take almost 50 days of uptime. Naturally at any "reasonable" publishing interval this time is even longer. The matter itself is also not addressed throughout the whole existing code that handled it before this change. (Though some consideration can be seen in some places, such as placing messages at the end of the incoming message linked list if no better place was found) 

#### Locking on m_cache to get the semaphore
I've considered making a separate locking object for the semaphore management, but decided it is not needed. The message worker would need to obtain m_cache lock later anyway, and momentarily obtaining it is not harmful for the overall flow.
Only in cases of serious contention between new PublishResponses coming in and workers attempting to work would this cause any problems.

#### Callbacks that "take a long time"
This change will naturally suffer from callbacks that take a long time to invoke. In our use case, each callback message is passed into an ActionBlock for handling, so our callbacks are fast. But Other clients may invoke much more code on these callbacks.
Sequential publishing means this capacity is possibly bottlenecked. Sequential publishing should be used for its intended purpose and with callbacks that do not hold up their calling thread for a long time. To ensure proper sequential callbacks, they cannot just be started in order, they have to be processed fully in order. 

#### Changing this property while the Subscription is active
There is limited support to on-the-fly changes to this property, and this is not the intended use case. It is meant to be set once and ideally never changed while messages are being processed.

If users need certain items properly sequenced and some items they can accept out-of-order or ignore outdated messages, they can do this by defining two separate Subscription objects, same as they would if they needed different Publishing Intervals. 

#### Why semaphore?
At first I had considered using ActionBlock from TPL DataFlow and limiting its concurrency to the number of desired message workers, but I had opted not to add a dependency on DataFlow only for this purpose. (Referencing all of DataFlow just for ActionBlock's automatic concurrency limiting is wasteful.

I had also considered using a Limited Concurrency Task Scheduler implementation and queueing the message workers on that instead of the normal ThreadPool via Task.Run, but that is similarly more complex than it needs to be.

#### Why async Task? What was wrong with Void?
While being on a new Task from the ThreadPool anyway, the worker would still occupy a task from the ThreadPool if it was using the synchronous Wait() method, which is a blocking call. By using WaitAsync, the ThreadPool task goes "back" to the ThreadPool until the semaphore is released. 

### Disclaimer - I am not an OPC UA expert
Please do not assume I have "done all my homework" with regard to these changes. I have attempted to learn as much as I can in the time I was working on this change, but I fully expect to have missed a few spots and specifics of the OPC UA protocol.

I have done some testing in our application to verify the out-of-order problem is solved, and that no significant delay is introduced by the additional work done to facilitate this.
2021-09-16 18:58:51 +02:00
dependabot[bot] 85516192fb Bump System.Security.Cryptography.Cng from 4.4.0 to 5.0.0 (#1508)
Bumps [System.Security.Cryptography.Cng](https://github.com/dotnet/runtime) from 4.4.0 to 5.0.0.
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](https://github.com/dotnet/runtime/commits/v5.0.0)

---
updated-dependencies:
- dependency-name: System.Security.Cryptography.Cng
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-16 07:58:01 +02:00
Martin Regen 2b54136969 Add missing vars in session less message (#1505)
**Type of Issue**
[X] Bug [ ] Enhancement [ ] Compliance [ ] Question [ ] Help wanted

The `SessionLessServiceMessage` misses the urisVersion field and localeIds

https://reference.opcfoundation.org/v104/Core/docs/Part4/6.3.2/

The urisVersion field is a VersionTime.
The urisVersion was misspelled in the Nodeset as an array. Nodeset was fixed in errata 1.04.8
2021-09-13 15:53:20 +02:00
Martin Regen a67714147d Support supplied keys and RSACng for the cert generator (#1507)
- Allow to call SetRSAPublicKey without Issuer being set
- Support to create self signed CA cert with supplied keys
- Test case for RSACng on .NET framework and .NET Core 3.1

Issue reported by @eoursel
2021-09-13 15:48:27 +02:00
Martin Regen dad6bcd8da Add API for multiple CRL distribution points (#1504)
fixes #1475 
Co-authored-by: symarchand <sylvain.marchand@capgemini.com>
2021-09-13 10:08:34 +02:00
Martin Regen a4bf0ab174 Complex types client can ignore isoptional fields for structure (#1503)
fixes #1476 
 Improve IOP, some recent ModelCompiler versions (starting with errata 1.04.9) produce invalid output and all IsOptional fields have become true by default, causing the complex types client to bail out for Structures created with this ModelCompiler release. However, the IsOptional field can be ignored.
ModelCompiler is fixed in 1.04.10 and greater
2021-09-13 09:18:30 +02:00
Martin Regen 21546b0aba Remove the code which allows to accept CRL (#1502)
fixes #1343

remove a inofficial test code which allowed a CRL to be decoded from the AddCertificate blob

https://mantis.opcfoundation.org/view.php?id=6342
2021-09-13 07:44:37 +02:00
Martin Regen 3c7e6330c5 Add a test if the app name has locale == null (#1501) 2021-09-13 07:42:44 +02:00
Martin Regen 76afe829b4 Add async versions of subscription API to session client (#1498)
fixes #919 and #921

- enable async client stubs in core
- add async versions for subscription management
- APM versions will not be included...

based on PR #919 from @mibos-kremer

Co-authored-by: Michiel <m.bos@kremer.nl>
2021-09-07 16:23:00 +02:00
opcfoundation-org 9b89bd070f Modelcompiler 1.04.10 (#1492)
* Changes needed for model compiler needed for Errata 1.04.10. 
* Errata 1.04.10.
2021-09-03 19:38:31 +02:00
Martin Regen 4a2f13efaf Improve https clien/server support (#1490)
- add support for security header in client/server libs
fixes #1118
2021-08-20 16:07:10 +02:00
dependabot[bot] cff75467fc Bump Mono.Options from 6.6.0.161 to 6.12.0.148 (#1489)
Bumps Mono.Options from 6.6.0.161 to 6.12.0.148.

---
updated-dependencies:
- dependency-name: Mono.Options
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-20 12:22:18 +03:00
dependabot[bot] 327c4124a7 Bump BenchmarkDotNet from 0.13.0 to 0.13.1 (#1479)
Bumps [BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet) from 0.13.0 to 0.13.1.
- [Release notes](https://github.com/dotnet/BenchmarkDotNet/releases)
- [Commits](https://github.com/dotnet/BenchmarkDotNet/compare/v0.13.0...v0.13.1)

---
updated-dependencies:
- dependency-name: BenchmarkDotNet
  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>
2021-08-20 12:20:09 +03:00
Suciu Mircea Adrian 198cec64bf Enhance GetBuiltintype to support simple datatypes (#1488)
* Return the correct BuiltInType for Simple numeric type ids in nanespace 0

* Added unit test BuiltInTypeOfSimpleDataTypes
2021-08-19 16:36:18 +03:00
dependabot[bot] 105d2115c3 Bump Microsoft.IO.RecyclableMemoryStream from 2.1.2 to 2.1.3 (#1487)
Bumps [Microsoft.IO.RecyclableMemoryStream](https://github.com/Microsoft/Microsoft.IO.RecyclableMemoryStream) from 2.1.2 to 2.1.3.
- [Release notes](https://github.com/Microsoft/Microsoft.IO.RecyclableMemoryStream/releases)
- [Changelog](https://github.com/microsoft/Microsoft.IO.RecyclableMemoryStream/blob/master/CHANGES.md)
- [Commits](https://github.com/Microsoft/Microsoft.IO.RecyclableMemoryStream/compare/2.1.2...2.1.3)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-19 08:10:38 +02:00
Dmitry Tikhonov c37f66cfeb Fix the behavior in case of the server is reachable only via an alternate address (#1480)
Fix the behavior in case of the server is reachable only via an alternate address - this alternate address matching the address, the client provides, is added to the list of accessible addresses so that the TranslateApplicationDescription method works correctly and the client gets back appropriate endpoints with the corresponding alternate address within them (#1480)
2021-08-19 08:10:01 +02:00
Martin Regen 73e0e59f98 macOS mono build fix, Https tests, bench improvements (#1486)
- on VS2019 for mac the https lib doesn't build, now get the properties at runtime to set server validation callback
- add client tests for https
- fix an issue with SslProtocol selection, where tools recommend None it only works on all platform combinations if Tls12 is used
- use the benchmark .NET command line parser 
- benchmarks for StreamWriter buffer size
- StreamWriter default buffer size reduced to 1k, according to bench results best compromise
fixes #1443
2021-08-18 11:01:04 +02:00
dependabot[bot] cca892357b Bump Microsoft.NET.Test.Sdk from 16.10.0 to 16.11.0 (#1482)
Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.10.0 to 16.11.0.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Commits](https://github.com/microsoft/vstest/compare/v16.10.0...v16.11.0)

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-16 22:16:12 +02:00
Alin Moldovean b5421ea391 Compliance fixes for OperationLimits and SetTriggering (#1469) 2021-07-26 11:33:41 +03:00
opcfoundation-org ad0a5afbbe Create SECURITY.md (#1471) 2021-07-26 10:06:51 +03:00
dependabot[bot] 1a9948ac09 Bump coverlet.collector from 3.0.3 to 3.1.0 (#1464)
Bumps [coverlet.collector](https://github.com/coverlet-coverage/coverlet) from 3.0.3 to 3.1.0.
- [Release notes](https://github.com/coverlet-coverage/coverlet/releases)
- [Commits](https://github.com/coverlet-coverage/coverlet/commits/v3.1.0)

---
updated-dependencies:
- dependency-name: coverlet.collector
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-25 16:27:47 +02:00
Suciu Mircea Adrian 98634b1cc7 Fixes issue #1462 (#1465)
* Added default switch case for the CreateStore method; reported in issue #1462
2021-07-23 13:41:05 +03:00
dependabot[bot] de6f86ac77 Bump Serilog.Sinks.Console from 3.1.1 to 4.0.0 (#1459)
Bumps [Serilog.Sinks.Console](https://github.com/serilog/serilog-sinks-console) from 3.1.1 to 4.0.0.
- [Release notes](https://github.com/serilog/serilog-sinks-console/releases)
- [Commits](https://github.com/serilog/serilog-sinks-console/compare/v3.1.1...v4.0.0)
2021-07-20 09:11:24 +02:00
Martin Regen c435e5844d Improve JsonDecoder StreamWriter dispose (#1448)
- only dispose StreamWriter if owned by JsonEncoder
- only dispose if dispose is called
- on external stream writer, return text by using reflection on basestream, if memorystream is used
- improve benchmark common code
- fixes #1444
2021-07-09 07:44:54 +02:00
Alin Moldovean 08164fe04a MetaData support for PubSub library (#1452)
* Metadata support
* Fixes for UaPubSub.
* Add support for delta frames.
2021-07-08 19:29:24 +03:00
Martin Regen b9ad021e11 Fix Nuget build (#1445)
Client proj lacks definition of SIGNASSEMBLY, bump nuget dependencies
2021-07-07 09:30:06 +02:00
Martin Regen 0236d082b1 Create client and server test projects, increase test coverage (#1434)
- Add Operation limit parameter and fix server. Fixes #1363 
- Add client/server test projects
- Add client and server fixture for test runs
- Server tests can test services without client connection
- Client tests can use common services to write tests which can run directly on server on via client server connection
- Increase code coverage > 50%
- Code coverage excludes the generated code
- Improve codecoverage local tests with report (see Tests/codecoverage scripts)
- Add a benchmark framework to client server tests
2021-07-06 18:01:54 +02:00
AYDIN HOMAY d972f80c2f Separated core projects from sample projects in solution level (#1428)
* Seperated core projects from sample projects in solution level
2021-06-25 10:14:41 +03:00
Alin Moldovean a90024b5de Make ApplicationConfiguration.FixupAppConfig() public. (#1431) 2021-06-24 11:33:49 +03:00
Martin Regen 96ecb4dd9c Add a no file fluent API for application configuration. (#1422)
* Add no file configuration fluent API
* ensure secure settings are produced by default
* most if not all settings can be reached by .Set/.Add functions
* switched gds tests to use no file config (also good as starter)
2021-06-15 19:14:09 +02:00
Martin Regen 24f90c410a Add interfaces IServiceMessageContext, IEncodeableFactory (#1407)
* use IServiceMessageContext instead of ServiceMessageContext across the board.
* same for IEncodeableFactory
2021-06-11 16:35:46 +02:00
dependabot[bot] c5b01615d7 Bump NUnit3TestAdapter from 3.17.0 to 4.0.0 (#1421)
Bumps [NUnit3TestAdapter](https://github.com/nunit/nunit3-vs-adapter) from 3.17.0 to 4.0.0.
- [Release notes](https://github.com/nunit/nunit3-vs-adapter/releases)
- [Commits](https://github.com/nunit/nunit3-vs-adapter/compare/V3.17...V4.0.0)

---
updated-dependencies:
- dependency-name: NUnit3TestAdapter
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-09 19:23:03 +02:00
Martin Regen 38dd899771 Add benchmark template to test project (#1415)
* benchmark template
* fix (C) and new warnings
* limit to C# version 7.3 to catch build errors earlier
2021-06-05 10:50:32 +02:00
Martin Regen 9923141e70 Enable .NET analyzers for all projects (#1414)
* Enable .NET analyzers for all projects
* fix all new warnings, mostly security and perf
2021-06-05 07:58:38 +02:00
Alin Moldovean 8406716bf9 Fixes #1302. Use value from OnReadUserAccessLevel at Read/WriteNonValueAttribute if handler exists. (#1413) 2021-05-31 09:15:41 +03:00
dependabot[bot] afe352ce3b Bump Microsoft.NET.Test.Sdk from 16.9.4 to 16.10.0 (#1412)
Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.9.4 to 16.10.0.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Commits](https://github.com/microsoft/vstest/compare/v16.9.4...v16.10.0)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-28 08:34:12 +02:00
Martin Regen 8a986f433a Improve server request handler (#1411)
-no need to search request list for every completed request, only if operation deadline is specified
-move timer clean up to timer callback
2021-05-25 17:53:18 +02:00
Alin Moldovean be41459e3b Fixes #1403 - Thread safe when setting MinimumSamplingInterval (#1409) 2021-05-25 13:37:50 +03:00
dependabot[bot] 4913c2b586 Bump NunitXml.TestLogger from 3.0.97 to 3.0.107 (#1408)
Bumps [NunitXml.TestLogger](https://github.com/spekt/nunit.testlogger) from 3.0.97 to 3.0.107.
- [Release notes](https://github.com/spekt/nunit.testlogger/releases)
- [Changelog](https://github.com/spekt/nunit.testlogger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/spekt/nunit.testlogger/compare/v3.0.97...v3.0.107)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-21 10:51:47 +03:00
Suciu Mircea Adrian 2dfedef0bd Fixes brought to the process of validating permissions (#1406)
* Fixed call to ValidatePermissions under TranslateBrowsePath service

* Fixed adding default permission values to the metadata under GetPermissionMetadata method
2021-05-20 17:01:52 +03:00
Nick 6d232726b4 Preferer a higher SecurityMode over SecurityLevel in CoreClientUtils.SelectEndpoint() (#1405) 2021-05-20 17:01:30 +03:00
Alin Moldovean af6b2b448b Update CTT project - remove "Time" node. (#1401) 2021-05-12 16:00:23 +02:00
Alin Moldovean f332d87f5a Change UaPublisher trigger from ManualResetEvent to Timer (#1399)
* Change UaPublisher trigger from ManualResetEvent to Timer
2021-05-12 16:16:07 +03:00
Alin Moldovean 923597eac2 improve encode/decode for array/matrix of Iencodeable (#1398)
Add tests for encode/decode of array/matrix of all IEncodeable
2021-05-12 15:10:11 +03:00
Alin Moldovean a5e1f4c8cd PubSub fixes (#1394) 2021-05-12 13:33:29 +03:00