Fix OPC UA adapter: pass connection details, certificate stores, endpoint discovery
- DataConnectionActor now stores and passes connection details to adapter ConnectAsync - DataConnectionManagerActor passes connection details when creating actor - RealOpcUaClient uses DiscoveryClient for endpoint selection with no-security preference - Added certificate trust store paths to prevent TrustedIssuerCertificates error - Sanitize connection names for Akka actor paths (replace spaces)
This commit is contained in:
@@ -58,14 +58,18 @@ public class DataConnectionActor : UntypedActor, IWithStash, IWithTimers
|
||||
private int _totalSubscribed;
|
||||
private int _resolvedTags;
|
||||
|
||||
private readonly IDictionary<string, string> _connectionDetails;
|
||||
|
||||
public DataConnectionActor(
|
||||
string connectionName,
|
||||
IDataConnection adapter,
|
||||
DataConnectionOptions options)
|
||||
DataConnectionOptions options,
|
||||
IDictionary<string, string>? connectionDetails = null)
|
||||
{
|
||||
_connectionName = connectionName;
|
||||
_adapter = adapter;
|
||||
_options = options;
|
||||
_connectionDetails = connectionDetails ?? new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
protected override void PreStart()
|
||||
@@ -204,7 +208,7 @@ public class DataConnectionActor : UntypedActor, IWithStash, IWithTimers
|
||||
{
|
||||
_log.Debug("[{0}] Attempting connection...", _connectionName);
|
||||
var self = Self;
|
||||
_adapter.ConnectAsync(new Dictionary<string, string>()).ContinueWith(t =>
|
||||
_adapter.ConnectAsync(_connectionDetails).ContinueWith(t =>
|
||||
{
|
||||
if (t.IsCompletedSuccessfully)
|
||||
return new ConnectResult(true, null);
|
||||
|
||||
@@ -44,9 +44,13 @@ public class DataConnectionManagerActor : ReceiveActor
|
||||
var adapter = _factory.Create(command.ProtocolType, command.ConnectionDetails);
|
||||
|
||||
var props = Props.Create(() => new DataConnectionActor(
|
||||
command.ConnectionName, adapter, _options));
|
||||
command.ConnectionName, adapter, _options, command.ConnectionDetails));
|
||||
|
||||
var actorRef = Context.ActorOf(props, command.ConnectionName);
|
||||
// Sanitize name for Akka actor path (replace spaces and invalid chars)
|
||||
var actorName = new string(command.ConnectionName
|
||||
.Select(c => char.IsLetterOrDigit(c) || "-_.*$+:@&=,!~';()".Contains(c) ? c : '-')
|
||||
.ToArray());
|
||||
var actorRef = Context.ActorOf(props, actorName);
|
||||
_connectionActors[command.ConnectionName] = actorRef;
|
||||
|
||||
_log.Info("Created DataConnectionActor for {0} (protocol={1})",
|
||||
|
||||
Reference in New Issue
Block a user