Milo:连接到(公共)OPC-UA-Server

时间:2017-04-25 14:42:38

标签: eclipse opc-ua milo

首先:我是OPCUA的新手。 :)

我正在尝试将Milo客户端连接到我们的服务器,但并不真正了解哪里出错了。示例客户端和服务器可以很好地协同工作,但是当我尝试将客户端示例与其中一个公共OPC-UA-Test-Servers连接时,我得到了以下例外:

  

15:48:34.729 [ua-netty-event-loop-0] DEBUG   org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientAcknowledgeHandler    - 在通道上发送Hello消息= [id:0xc22800c2,L:/10.22.19.217:58947 - R:opcua.demo-this.com/52.233.134.134:51210]。 15:48:34.729 [ua-netty-event-loop-0] WARN io.netty.channel.DefaultChannelPipeline -   一个exceptionCaught()事件被触发,它到达了尾部   管道。它通常意味着管道中的最后一个处理程序   不处理异常。 java.io.IOException:现有连接   被远程主机强行关闭了   sun.nio.ch.SocketDispatcher.read0(Native Method)at   sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)at   sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)at at   sun.nio.ch.IOUtil.read(IOUtil.java:192)at   sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)at at   io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:221)     在   io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:898)     在   io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:242)     在   io.netty.channel.nio.AbstractNioByteChannel $ NioByteUnsafe.read(AbstractNioByteChannel.java:119)     在   io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528)     在   io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:485)     在   io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:399)     在io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:371)at   io.netty.util.concurrent.SingleThreadEventExecutor $ 2.run(SingleThreadEventExecutor.java:112)     在java.lang.Thread.run(Thread.java:745)15:48:39.612   [ForkJoinPool.commonPool-worker-1] DEBUG   org.eclipse.milo.opcua.stack.client.ClientChannelManager - 频道   bootstrap失败:超时等待确认   org.eclipse.milo.opcua.stack.core.UaException:超时等待   承认   org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientAcknowledgeHandler.lambda $ startHelloTimeout $ 4(UaTcpClientAcknowledgeHandler.java:156)     在   org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientAcknowledgeHandler $$ LAMBDA $ 27日/ 469017260.run(未知   来源)at   io.netty.util.HashedWheelTimer $ HashedWheelTimeout.expire(HashedWheelTimer.java:581)     在   io.netty.util.HashedWheelTimer $ HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:655)     在   io.netty.util.HashedWheelTimer $ Worker.run(HashedWheelTimer.java:367)     at java.lang.Thread.run(Thread.java:745)15:48:39.613 [main] ERROR   org.eclipse.milo.examples.client.ClientExampleRunner - 运行错误   示例:UaException:status = Bad_Timeout,message =超时等待   for acknowledge java.util.concurrent.ExecutionException:UaException:   status = Bad_Timeout,message =超时等待确认   java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)     在   java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1887)     在   org.eclipse.milo.examples.client.ClientExampleRunner.createClient(ClientExampleRunner.java:56)     在   org.eclipse.milo.examples.client.ClientExampleRunner.run(ClientExampleRunner.java:103)     在   org.eclipse.milo.examples.client.BrowseExample.main(BrowseExample.java:40)   引起:org.eclipse.milo.opcua.stack.core.UaException:超时   等待承认   org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientAcknowledgeHandler.lambda $ startHelloTimeout $ 4(UaTcpClientAcknowledgeHandler.java:156)     在   org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientAcknowledgeHandler $$ LAMBDA $ 27日/ 469017260.run(未知   来源)at   io.netty.util.HashedWheelTimer $ HashedWheelTimeout.expire(HashedWheelTimer.java:581)     在   io.netty.util.HashedWheelTimer $ HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:655)     在   io.netty.util.HashedWheelTimer $ Worker.run(HashedWheelTimer.java:367)     在java.lang.Thread.run(Thread.java:745)15:48:42.842   [threadDeathWatcher-2-1] DEBUG io.netty.buffer.PoolThreadCache - Freed   来自线程的2个线程局部缓冲区:ua-netty-event-loop-0

我拿了示例代码并删除了证书/密钥对,并将URL更改为opc.tcp://opcua.demo-this.com:51210/UA/SampleServer,因为公共服务器不需要授权:

SecurityPolicy securityPolicy = clientExample.getSecurityPolicy();
EndpointDescription[] endpoints = UaTcpStackClient.getEndpoints("opc.tcp://opcua.demo-this.com:51210/UA/SampleServer").get();

EndpointDescription endpoint = Arrays.stream(endpoints)
    .filter(e -> e.getSecurityPolicyUri().equals(securityPolicy.getSecurityPolicyUri()))
    .findFirst().orElseThrow(() -> new Exception("no desired endpoints returned"));

logger.info("Using endpoint: {} [{}]", endpoint.getEndpointUrl(), securityPolicy);

loader.load();

OpcUaClientConfig config = OpcUaClientConfig.builder()
    .setApplicationName(LocalizedText.english("eclipse milo opc-ua client"))
    .setApplicationUri("urn:eclipse:milo:examples:client")
    //.setCertificate(loader.getClientCertificate())
    //.setKeyPair(loader.getClientKeyPair())
    .setEndpoint(endpoint)
    .setIdentityProvider(clientExample.getIdentityProvider())
    .setRequestTimeout(uint(5000))
    .build();

return new OpcUaClient(config);

我错过了什么?

提前问候和感谢:)

1 个答案:

答案 0 :(得分:0)

埋藏在堆栈跟踪中是真正的问题:UaException: timed out waiting for acknowledge

也许您的防火墙或网络设置阻止它,或者服务器可能没有将其发回,但问题是客户端从未收到Acknowledge消息以响应其Hello }。

FWIW,我可以毫无问题地对该公共服务器运行ReadExample。在ReadExample我覆盖了getSecurityPolicy()并返回了SecurityPolicy.None,而ClientExampleRunner只更换了端点网址。