0

我正在为 Apache NiFi 开发一项服务,该服务应该能够订阅 OPCUA 服务器上的一些变量。我无法让服务连接到 OPCUA 服务器。这是堆栈跟踪:

java.util.concurrent.ExecutionException: UaException: status=Bad_Timeout, message=timed out waiting for secure channel
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at com.hashmapinc.tempus.processors.StandardMiloOPCUAService.createClient(StandardMiloOPCUAService.java:75)
at com.hashmapinc.tempus.processors.StandardMiloOPCUAService.onEnabled(StandardMiloOPCUAService.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:137)
at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:125)
at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:70)
at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:47)
at org.apache.nifi.controller.service.StandardControllerServiceNode$2.run(StandardControllerServiceNode.java:400)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
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)
Caused by: org.eclipse.milo.opcua.stack.core.UaException: timed out waiting for secure channel
at org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientMessageHandler.lambda$handlerAdded$2(UaTcpClientMessageHandler.java:151)
at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:581)
at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:655)
at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:367)
... 1 common frames omitted

所以它在等待安全通道时超时。当我向服务提供一些虚假 IP 地址时,它只是说连接超时。

这是我用来创建客户端的代码:

private OpcUaClient createClient() throws Exception {
    EndpointDescription[] endpoints;
    endpoints = UaTcpStackClient
            .getEndpoints("opc.tcp://theaddress:49320")
            .get();
    EndpointDescription endpoint = endpoints[0];
    OpcUaClientConfig config = OpcUaClientConfig.builder()
            .setApplicationName(LocalizedText.english("MinimalClient"))
            .setApplicationUri("urn:theurn")
            .setCertificate(null)
            .setKeyPair(null)
            .setEndpoint(endpoint)
            .setMaxResponseMessageSize(uint(50000))
            .setIdentityProvider(new AnonymousProvider())
            .setRequestTimeout(uint(5000))
            .build();
    return new OpcUaClient(config);
}

这可能是防火墙问题吗?它是否连接到服务器然后无法获得安全通道?仅供参考:服务器允许匿名身份并具有 SecurityPolicy:NONE。

4

0 回答 0