Hi - Java SDK 0.29.2 works fine, but the recently released 0.30.2 fails to connect ZitiContext objects. Versions 0.30.0 and 0.30.1 have the same problem.
I'm calling ZitiContext zitiContext = Ziti.newContext(identityConfig);
In 0.29.2 zitiContext
status is initially Loading
and soon changes to Active
. The context is usable as soon as it activates.
In 0.30.2 zitiContext
status is permanently Loading
and is unusable.
The only difference between the two tests is the OpenZiti Maven dependency.
For completeness, here's my code...
I'm running under Windows using Java 21
Maven
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.duncan.testing</groupId>
<artifactId>ziti-demo</artifactId>
<version>1.0-MASTER</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
<maven-compiler-plugin>3.11.0</maven-compiler-plugin>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.openziti/ziti -->
<dependency>
<groupId>org.openziti</groupId>
<artifactId>ziti</artifactId>
<!-- <version>0.28.1</version>-->
<version>0.29.2</version>
<!-- <version>0.30.2</version>-->
</dependency>
</dependencies>
</project>
Java
import org.openziti.IdentityConfig;
import org.openziti.Ziti;
import org.openziti.ZitiContext;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
public class ZitiTestClient {
public static void main(String[] args) {
System.out.println("Started application");
try {
new ZitiTestClient().doZitiNewContext();
} catch (Throwable t) {
t.printStackTrace();
}
System.out.println("Finished application");
}
private void doZitiNewContext() throws Exception {
System.out.println("Trying Ziti.newContext()");
try {
IdentityConfig identityConfig = IdentityConfig.load("Duncan App Beta.json");
ZitiContext zitiContext = Ziti.newContext(identityConfig);
// Wait for context to be ready
System.out.println(" Status: " + zitiContext.getStatus());
while (ZitiContext.Status.Loading.INSTANCE.equals(zitiContext.getStatus())) {
TimeUnit.MILLISECONDS.sleep(200);
System.out.println(" Checking Status: " + zitiContext.getStatus());
}
if (!ZitiContext.Status.Active.INSTANCE.equals(zitiContext.getStatus()))
throw new Exception("ZitiContext failed to load - " + zitiContext.getStatus());
// Even though the context is Active, it will take a little longer for the service definitions to be loaded
TimeUnit.SECONDS.sleep(3);
System.out.println(" Id: " + zitiContext.getId());
printContexts();
// Try connecting to a service
//dialService(zitiContext);
} finally {
destroyContexts();
}
}
private void printContexts() {
Collection<ZitiContext> zitiContexts = Ziti.getContexts();
System.out.println("Printing " + zitiContexts.size() + " ZitiContexts");
for (ZitiContext zitiContext : zitiContexts) {
StringWriter strWriter = new StringWriter();
zitiContext.dump(strWriter);
System.out.println("Ziti Context\n" + strWriter);
}
}
private void destroyContexts() {
Collection<ZitiContext> zitiContexts = new ArrayList<>(Ziti.getContexts());
System.out.println("Destroying " + zitiContexts.size() + " ZitiContexts");
for (ZitiContext zitiContext : zitiContexts) {
System.out.println(" Destroying " + zitiContext.name());
zitiContext.destroy();
Ziti.removeContext(zitiContext);
}
}
}
Please could someone confirm the problem.