opcua_server/lib.rs
1#![warn(missing_docs)]
2
3//! A general implementation of an OPC-UA server.
4//!
5//! Support for subscriptions, complex address spaces, methods, all OPC-UA services,
6//! node set import, and more.
7//!
8//! The server starts a tokio `task` for each connection, and another task for each incoming
9//! service call.
10//!
11//! See docs for the main `opcua` crate for details on usage.
12
13pub mod address_space;
14pub mod authenticator;
15mod builder;
16mod config;
17pub mod diagnostics;
18#[cfg(feature = "discovery-server-registration")]
19mod discovery;
20mod identity_token;
21mod info;
22pub mod node_manager;
23mod reverse_connect;
24mod server;
25mod server_handle;
26mod server_status;
27mod session;
28mod subscriptions;
29mod transport;
30
31pub use builder::ServerBuilder;
32pub use config::*;
33pub use identity_token::IdentityToken;
34pub use info::ServerInfo;
35pub use opcua_types::event_field::EventField;
36pub use reverse_connect::ReverseConnectTargetConfig;
37pub use server::Server;
38pub use server_handle::ServerHandle;
39pub use server_status::ServerStatusWrapper;
40pub use session::continuation_points::ContinuationPoint;
41pub use subscriptions::{
42 CreateMonitoredItem, MonitoredItem, MonitoredItemHandle, SessionSubscriptions, Subscription,
43 SubscriptionCache, SubscriptionState,
44};
45
46/// Utilities for efficiently notifying subscriptions.
47///
48/// See [SubscriptionCache::data_notifier] and [SubscriptionCache::event_notifier].
49pub mod notify {
50 pub use super::subscriptions::{
51 MonitoredItemEntry, SubscriptionDataNotifier, SubscriptionDataNotifierBatch,
52 SubscriptionEventNotifier, SubscriptionEventNotifierBatch,
53 };
54}
55
56/// Contains constaints for default configuration values.
57/// These are for the most part possible to override through server configuration.
58pub mod constants {
59 /// The default hello timeout period in seconds
60 pub const DEFAULT_HELLO_TIMEOUT_SECONDS: u32 = 5;
61 /// Default OPC UA server port for this implementation
62 pub const DEFAULT_RUST_OPC_UA_SERVER_PORT: u16 = 4855;
63 /// Default maximum number of monitored items per subscription
64 pub const DEFAULT_MAX_MONITORED_ITEMS_PER_SUB: usize = 1000;
65 /// Default, well known address for TCP discovery server
66 pub const DEFAULT_DISCOVERY_SERVER_URL: &str = "opc.tcp://localhost:4840/UADiscovery";
67
68 // Internally controlled values
69
70 /// The polling interval in millis on subscriptions and monitored items. The more
71 /// fine-grained this is, the more often subscriptions will be checked for changes. The minimum
72 /// publish interval cannot be less than this.
73 pub const SUBSCRIPTION_TIMER_RATE_MS: u64 = 100;
74 /// Minimum publishing interval for subscriptions
75 pub const MIN_PUBLISHING_INTERVAL_MS: f64 = SUBSCRIPTION_TIMER_RATE_MS as f64;
76 /// Minimum sampling interval on monitored items
77 pub const MIN_SAMPLING_INTERVAL_MS: f64 = SUBSCRIPTION_TIMER_RATE_MS as f64;
78 /// Maximum data change queue allowed by clients on monitored items
79 pub const MAX_DATA_CHANGE_QUEUE_SIZE: usize = 10;
80 /// Maximum time in MS that a session can be inactive before a timeout
81 pub const MAX_SESSION_TIMEOUT: u64 = 60_000;
82 /// Default keep alive count
83 pub const DEFAULT_KEEP_ALIVE_COUNT: u32 = 10;
84 /// Maximum keep alive count
85 pub const MAX_KEEP_ALIVE_COUNT: u32 = 30000;
86 /// Maximum browse continuation points
87 pub const MAX_BROWSE_CONTINUATION_POINTS: usize = 5000;
88 /// Maximum history continuation points
89 pub const MAX_HISTORY_CONTINUATION_POINTS: usize = 500;
90 /// Maximum query continuation points
91 pub const MAX_QUERY_CONTINUATION_POINTS: usize = 500;
92
93 /// Maximum number of nodes in a TranslateBrowsePathsToNodeIdsRequest
94 pub const MAX_NODES_PER_TRANSLATE_BROWSE_PATHS_TO_NODE_IDS: usize = 100;
95 /// Maximum number of ReadValueIds in a Read request.
96 pub const MAX_NODES_PER_READ: usize = 10000;
97 /// Maximum number of WriteValues in a Write request.
98 pub const MAX_NODES_PER_WRITE: usize = 10000;
99 /// Maximum number of method calls in a Call request.
100 pub const MAX_NODES_PER_METHOD_CALL: usize = 100;
101 /// Maximum number of nodes in a Browse or BrowseNext request.
102 pub const MAX_NODES_PER_BROWSE: usize = 1000;
103 /// Maximum number of nodes per register/deregister request.
104 pub const MAX_NODES_PER_REGISTER_NODES: usize = 1000;
105 /// Maximum number of nodes per node manaument operation
106 pub const MAX_NODES_PER_NODE_MANAGEMENT: usize = 1000;
107 /// Maximum number of references per reference management operation.
108 pub const MAX_REFERENCES_PER_REFERENCE_MANAGEMENT: usize = 1000;
109 /// Maximum number of monitored items per operation.
110 pub const MAX_MONITORED_ITEMS_PER_CALL: usize = 1000;
111 /// Maximum number of nodes per history read for data.
112 pub const MAX_NODES_PER_HISTORY_READ_DATA: usize = 100;
113 /// Maixmum number of nodes per history read for events.
114 pub const MAX_NODES_PER_HISTORY_READ_EVENTS: usize = 100;
115 /// Maximum number of nodes per history update call. Not separate constants
116 /// for data and events because update may mix the two.
117 pub const MAX_NODES_PER_HISTORY_UPDATE: usize = 100;
118 /// Maximum number of node descriptions per query call.
119 pub const MAX_NODE_DESCS_PER_QUERY: usize = 100;
120 /// Maximum number of references to return per query data set.
121 pub const MAX_REFERENCES_QUERY_RETURN: usize = 100;
122 /// Maximum number of data sets to return per query.
123 pub const MAX_DATA_SETS_QUERY_RETURN: usize = 1000;
124 /// Maximum number of subscriptions per subscription management call, where applicable.
125 pub const MAX_SUBSCRIPTIONS_PER_CALL: usize = 10;
126
127 /// Maximum number of sessions active on a server.
128 pub const MAX_SESSIONS: usize = 20;
129 /// Maximum number of references per node during Browse or BrowseNext.
130 pub const MAX_REFERENCES_PER_BROWSE_NODE: usize = 1000;
131
132 /// Maximum number of subscriptions per session.
133 pub const MAX_SUBSCRIPTIONS_PER_SESSION: usize = 10;
134 /// Maximum number of pending publish requests per session before further requests are rejected.
135 pub const MAX_PENDING_PUBLISH_REQUESTS: usize = 20;
136 /// Maximum number of pending publish requsts per subscription. The smaller of this * number of subscriptions
137 /// and max_pending_publish_requests is used.
138 pub const MAX_PUBLISH_REQUESTS_PER_SUBSCRIPTION: usize = 4;
139
140 /// Default publish timeout in milliseconds.
141 pub const DEFAULT_PUBLISH_TIMEOUT_MS: u64 = 30000;
142 /// Maximum number of notifications per publish, can be set lower by the client.
143 pub const MAX_NOTIFICATIONS_PER_PUBLISH: u64 = 0;
144 /// Maximum number of queued notifications. Any notifications beyond this are dropped.
145 pub const MAX_QUEUED_NOTIFICATIONS: usize = 20;
146
147 /// Receive buffer size default.
148 pub const RECEIVE_BUFFER_SIZE: usize = u16::MAX as usize;
149 /// Send buffer size default.
150 pub const SEND_BUFFER_SIZE: usize = u16::MAX as usize;
151}