Top Related Projects
Open source implementation of OPC UA (OPC Unified Architecture) aka IEC 62541 licensed under Mozilla Public License v2.0
Quick Overview
Eclipse Milo is an open-source implementation of OPC UA (Open Platform Communications Unified Architecture) for Java. It provides a complete stack for building OPC UA clients and servers, enabling industrial automation and IoT applications to communicate using this standardized protocol.
Pros
- Comprehensive implementation of OPC UA, supporting both client and server-side development
- Active development and maintenance by the Eclipse Foundation
- Extensive documentation and examples available
- Supports various security features and encryption methods
Cons
- Steep learning curve for developers new to OPC UA
- Can be resource-intensive for embedded systems
- Limited support for older OPC specifications (e.g., OPC DA)
- Some users report occasional stability issues in complex scenarios
Code Examples
- Creating an OPC UA client and connecting to a server:
OpcUaClient client = OpcUaClient.create(
"opc.tcp://localhost:4840",
endpoints ->
endpoints.stream()
.filter(e -> e.getSecurityPolicyUri().equals(SecurityPolicy.None.getUri()))
.findFirst(),
configBuilder ->
configBuilder
.setApplicationName(LocalizedText.english("Eclipse Milo OPC UA Client"))
.setApplicationUri("urn:eclipse:milo:examples:client")
.build()
);
client.connect().get();
- Reading a value from an OPC UA server:
NodeId nodeId = new NodeId(2, "HelloWorld/ScalarTypes/Int32");
DataValue value = client.readValue(0.0, TimestampsToReturn.Both, nodeId).get();
System.out.println("Value: " + value.getValue().getValue());
- Writing a value to an OPC UA server:
NodeId nodeId = new NodeId(2, "HelloWorld/ScalarTypes/Int32");
DataValue newValue = new DataValue(new Variant(42));
StatusCode statusCode = client.writeValue(nodeId, newValue).get();
System.out.println("Write status: " + statusCode);
Getting Started
To use Eclipse Milo in your Java project, add the following dependencies to your Maven pom.xml
:
<dependencies>
<dependency>
<groupId>org.eclipse.milo</groupId>
<artifactId>sdk-client</artifactId>
<version>0.6.6</version>
</dependency>
<dependency>
<groupId>org.eclipse.milo</groupId>
<artifactId>sdk-server</artifactId>
<version>0.6.6</version>
</dependency>
</dependencies>
Then, you can create a simple OPC UA client as shown in the first code example above. For more detailed instructions and examples, refer to the official Eclipse Milo documentation.
Competitor Comparisons
Open source implementation of OPC UA (OPC Unified Architecture) aka IEC 62541 licensed under Mozilla Public License v2.0
Pros of open62541
- Written in C, offering better performance and lower resource usage
- Highly portable, suitable for embedded systems and resource-constrained environments
- Provides a single-file distribution option for easy integration
Cons of open62541
- Less feature-rich compared to Milo
- Steeper learning curve for developers not familiar with C programming
- Limited built-in security features compared to Milo's Java-based implementation
Code Comparison
open62541 (C):
UA_Server *server = UA_Server_new();
UA_ServerConfig_setDefault(UA_Server_getConfig(server));
UA_Server_run(server, &running);
UA_Server_delete(server);
Milo (Java):
OpcUaServer server = OpcUaServer.create(config);
server.startup().get();
future.get();
server.shutdown().get();
Both examples demonstrate basic server creation and lifecycle management. open62541 uses a more C-style approach with explicit memory management, while Milo leverages Java's object-oriented features and garbage collection.
open62541 is better suited for embedded systems and performance-critical applications, while Milo offers a more feature-rich and developer-friendly experience for Java developers. The choice between them depends on the specific project requirements, target environment, and development team expertise.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Eclipse Milo
Milo is an open-source implementation of OPC UA (currently targeting 1.03). It includes a high-performance stack (channels, serialization, data structures, security) as well as client and server SDKs built on top of the stack.
Stack Overflow tag: milo
Mailing list: https://dev.eclipse.org/mailman/listinfo/milo-dev
Maven
Building Milo
Using JDK 8, run mvn clean install
from the project root.
To maintain compatibility with Java 8 it is recommended that you build using JDK 8, however the library is runtime compatible with versions 8 and later (e.g. JDK 11, JDK 17).
Releases
Releases are published to Maven Central and snapshots to Sonatype.
OPC UA Client SDK
<dependency>
<groupId>org.eclipse.milo</groupId>
<artifactId>sdk-client</artifactId>
<version>0.6.13</version>
</dependency>
OPC UA Server SDK
<dependency>
<groupId>org.eclipse.milo</groupId>
<artifactId>sdk-server</artifactId>
<version>0.6.13</version>
</dependency>
Referencing a SNAPSHOT
release requires the Sonatype snapshot repository be added to your pom file:
<repository>
<id>oss-sonatype</id>
<name>oss-sonatype</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
Public Demo Server
An internet-facing demo server is accessible at opc.tcp://milo.digitalpetri.com:62541/milo
.
It accepts both unsecured and secured connections. Before connecting with security you must upload your client's DER-encoded X509 certificate using the form at http://milo.digitalpetri.com.
Authenticate anonymously or with one of the following credential pairs:
user1
/password
user2
/password
admin
/password
The code powering the demo server is available here: https://github.com/digitalpetri/opc-ua-demo-server
Top Related Projects
Open source implementation of OPC UA (OPC Unified Architecture) aka IEC 62541 licensed under Mozilla Public License v2.0
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot