I have an echo service, and it works fine when I connect via Windows Desktop Edge.
But I'm struggling to connect from a client using the Java SDK.
This code extract fails on the first line
try (ZitiConnection conn = zitiContext.dial(serviceName)) {
// Communicate with the service
try {
doCommunication(conn);
} catch (Exception e) {
throw new Exception("Communication failed", e);
}
} catch (Exception e) {
throw new Exception("Failed to open connection with service", e);
}
Exception details
Caused by: java.net.ConnectException: exceeded maximum [2] retries creating circuit [c/32Tddt2CK]: error creating route for [s/32Tddt2CK] on [r/SiDCyFNjt] (error creating route for [c/32Tddt2CK]: failed to establish connection with terminator address 3ML6pE8lG401Ne3KLH82CB. error: (rejected by application))
at org.openziti.net.ZitiSocketChannel.doZitiHandshake$ziti(ZitiSocketChannel.kt:488) ~[ziti-0.27.5.jar:0.27.5]
at org.openziti.net.ZitiSocketChannel$doZitiHandshake$1.invokeSuspend(ZitiSocketChannel.kt) ~[ziti-0.27.5.jar:0.27.5]
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-2.0.20.jar:2.0.20-release-360]
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101) ~[kotlinx-coroutines-core-jvm-1.9.0.jar:?]
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113) ~[kotlinx-coroutines-core-jvm-1.9.0.jar:?]
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89) ~[kotlinx-coroutines-core-jvm-1.9.0.jar:?]
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589) ~[kotlinx-coroutines-core-jvm-1.9.0.jar:?]
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:823) ~[kotlinx-coroutines-core-jvm-1.9.0.jar:?]
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720) ~[kotlinx-coroutines-core-jvm-1.9.0.jar:?]
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707) ~[kotlinx-coroutines-core-jvm-1.9.0.jar:?]
and the service logs contains
[2025-02-28T13:28:07.218Z] ERROR tunnel-cbs:ziti_hosting.c:602 on_hosted_client_connect() hosted_service[echo.duncan] client[Duncan Client] failed to compute destination protocol: config specifies 'forwardProtocol', but client didn't send dst_protocol in app_
[2025-02-28T13:28:07.236Z] ERROR tunnel-cbs:ziti_hosting.c:602 on_hosted_client_connect() hosted_service[echo.duncan] client[Duncan Client] failed to compute destination protocol: config specifies 'forwardProtocol', but client didn't send dst_protocol in app_
The service was created in ZAC using Create Simple Service, and it works fine when tunneling using Windows Desktop Edge.
The error seems reasonable, as in Java I'm not specifying which protocol to use (TCP/UDP).
But how to set it?
There is another dial method that takes a ZitiAddress.Dial, but there is no documentation or samples, and I can't figure out how to use the parameters.
ZitiAddress.Dial dial = new ZitiAddress.Dial(serviceName, appData, "dialIdentity", "dialCallerId");
try (ZitiConnection conn = zitiContext.dial(dial)) {
Param 1 serviceName - yup, that's straightforward
Param 2 appData - It's just an Object, absolutely no idea whether this could be used to provide the protocol.
Param 3 identity - Might be the terminatorId if there is more than one terminator, but likely to be something else
Param 4 - callerId - Might be setting the the externalId for the application, but could be something else
In summary - when dialing using the Java SDK, how do I set the protocol to be forwarded to the service?