Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [milo-dev] eclipse milo client 3.0.5 gets stuck when disconnecting

hello, Kevin

thank you very much, patch works & now my tests pass,
hope it won't be long before we see 0.3.4 version released

On Thu, Oct 24, 2019 at 5:26 PM Kevin Herron <kevinherron@xxxxxxxxx> wrote:
Have you had a chance to test the PR yet?

On Tue, Oct 22, 2019 at 4:11 AM Kevin Herron <kevinherron@xxxxxxxxx> wrote:

Please verify this fixes the issue for you.

On Tue, Oct 22, 2019 at 4:01 AM Kevin Herron <kevinherron@xxxxxxxxx> wrote:
I will fix this for the 0.3.4 release. I've created an issue to track it here: https://github.com/eclipse/milo/issues/560

There will be a PR up soon that you can use to verify it has been fixed.

On Tue, Oct 22, 2019 at 3:33 AM Lenovo K3 Owner <lenovo.k3.1.owner@xxxxxxxxx> wrote:
Hello, Kevin

as a reminder we are observing strange problems after upgrading from milo 0.2.5 to 0.3.3 suddenly client freezes when i disconnect from serveror do read operations.

I prepared the refined example of when I observe thread block (even when reading data),
In example below there are 3 version of code of which second (main_stuck) stucks,
and this is behaviour that changed from milo 0.2.5. to milo 0.3.3,
sadly our coide relies heavily on building chains of completable futures, so before I start rewriting all our code to follow approach # 1 or # 3, 
I want to ask if such new behaviour is normal for milo 0.3.3 and will be forever or its just bug ?
btw: must say that for me these stucks are kinda unexpected I would rather see error messages if api usage is wrong



@Slf4j
public class DemoApplication {

private static final String url = "opc.tcp://qub-emulator:12345/example";

@SneakyThrows
public static void main_works(String[] args) {
OpcUaClient client = getClient();

client.connect().get();

debugServerInfo(client);

client.disconnect().get();

log.info("work is done");
}

@SneakyThrows
public static void main_stuck(String[] args) {
OpcUaClient client = getClient();
        //doesn't work - stucks on reading nodes
        CompletableFuture<?> connected = client.connect();

connected
.thenApply((a) -> debugServerInfo(client))
.thenApply((a) -> disconnect(client))
.get();

log.info("work is done");
}

@SneakyThrows
public static void main_works_with_chain_and_executor(String[] args) {
OpcUaClient client = getClient();

CompletableFuture<?> connected = client.connect();

ExecutorService executor = Executors.newSingleThreadExecutor(new DefaultThreadFactory("background", true));
connected
.thenApplyAsync((a) -> debugServerInfo(client), executor)
.thenApplyAsync((a) -> disconnect(client), executor)
.get();

log.info("work is done");
}


private static Object disconnect(OpcUaClient client) {
try {
return client.disconnect().get();
} catch (Exception e) {
log.error("cannot disconnect", e);
return e;
}
}

@SneakyThrows
private static OpcUaClient getClient() {
Optional<EndpointDescription> firstEndpoint = DiscoveryClient.getEndpoints(url).get()
.stream()
.filter(t -> t.getSecurityMode() == MessageSecurityMode.None)
.findFirst();

log.info("using endpoint {}", firstEndpoint.get());

OpcUaClientConfigBuilder configBuilder = OpcUaClientConfig.builder()
.setApplicationName(LocalizedText.english("some opc-ua client"))
.setApplicationUri("urn:some:client")
.setIdentityProvider(new AnonymousProvider())
.setEndpoint(firstEndpoint.get())
.setRequestTimeout(uint(5000))
.setCertificateValidator(new InsecureCertificateValidator());

OpcUaClientConfig config = configBuilder.build();
return new OpcUaClient(config, UaStackClient.create(config));
}

@SneakyThrows
private static Object debugServerInfo(OpcUaClient client) {
log.info("about to debug some server info");
ServerNode serverNode = client.getAddressSpace().getObjectNode(Identifiers.Server, ServerNode.class).get();
ServerState state = serverNode.getServerStatusNode().get().getState().get();
DateTime dateTime = serverNode.getServerStatusNode().get().getCurrentTime().get(5, TimeUnit.SECONDS);

log.info("state {}", state);
log.info("dateTime {}", dateTime);
return null;
}

}


On Tue, Oct 1, 2019 at 4:06 PM Kevin Herron <kevinherron@xxxxxxxxx> wrote:
Actually, I can reproduce it if I attempt a blocking disconnect while blocking on the callback from a connect:

client.connect().thenRun(() -> {
    try {
        client.disconnect().get();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
}).get();

For now I would suggest you modify your code so this is not happening.

On Tue, Oct 1, 2019 at 5:40 AM Kevin Herron <kevinherron@xxxxxxxxx> wrote:
I'm not sure how to reproduce this. Can you include a full thread dump or some additional logging?

On Tue, Oct 1, 2019 at 3:27 AM Lenovo K3 Owner <lenovo.k3.1.owner@xxxxxxxxx> wrote:
Hello Milo-dev,


I am observing rather strange problems after upgrading from milo 0.2.5
to 0.3.3

suddenly client freezes when i disconnect from server (i use as server zenon)
OpcUaClient client = ...
client.disconnect().get();


"milo-shared-thread-pool-0@21292" daemon prio=5 tid=0x72 nid=NA waiting
  java.lang.Thread.State: WAITING
          at sun.misc.Unsafe.park(Unsafe.java:-1)
          at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
          at java.util.concurrent.CompletableFuture$Signaller.block(CompletableFuture.java:1693)
          at java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3323)
          at java.util.concurrent.CompletableFuture.waitingGet(CompletableFuture.java:1729)
          at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
          at com.myproject.opcua.connection.OpcUaServerCommandExecutorTemplateServiceImpl.lambda$runInternal$2(OpcUaServerCommandExecutorTemplateServiceImpl.java:73)
          at com.myproject.opcua.connection.OpcUaServerCommandExecutorTemplateServiceImpl$$Lambda$1641.1531540324.apply(Unknown Source:-1)
          at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602)
          at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
          at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
          at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1962)
          at org.eclipse.milo.opcua.stack.core.util.FutureUtils$CompletionBuilder.lambda$with$0(FutureUtils.java:163)
          at org.eclipse.milo.opcua.stack.core.util.FutureUtils$CompletionBuilder$$Lambda$1642.372612879.accept(Unknown Source:-1)
          at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760)
          at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:736)
          at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
          at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1962)
          at org.eclipse.milo.opcua.sdk.client.session.SessionFsmFactory.lambda$configureActiveState$24(SessionFsmFactory.java:512)
          at org.eclipse.milo.opcua.sdk.client.session.SessionFsmFactory$$Lambda$1457.797901058.execute(Unknown Source:-1)
          at com.digitalpetri.strictmachine.dsl.ActionBuilder$$Lambda$1315.1332887918.accept(Unknown Source:-1)
          at com.digitalpetri.strictmachine.dsl.ActionBuilder$PredicatedTransitionAction.execute(ActionBuilder.java:76)
          at com.digitalpetri.strictmachine.StrictMachine$PollAndEvaluate.lambda$run$0(StrictMachine.java:207)
          at com.digitalpetri.strictmachine.StrictMachine$PollAndEvaluate$$Lambda$1366.1743722390.accept(Unknown Source:-1)
          at java.util.ArrayList.forEach(ArrayList.java:1257)
          at com.digitalpetri.strictmachine.StrictMachine$PollAndEvaluate.run(StrictMachine.java:198)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          at java.lang.Thread.run(Thread.java:748)



or when I try to read server node (at lest some nodes are working).

ServerNode serverNode = client.getAddressSpace().getObjectNode(Identifiers.Server, ServerNode.class).get();


--
Best regards,
 Mikalai                      
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/milo-dev

Back to the top