我正在尝试利用apache camel-web3j组件连接到本地ganache testnet节点:https://github.com/apache/camel/blob/master/components/camel-web3j/src/main/docs/web3j-component.adoc
即使未正式发布,我也可以在本地构建它,并将其作为本地依赖项包含在我的Maven项目中。当我按照github网站上的说明进行操作时,收到错误消息:
java.lang.RuntimeException: Provided file socket cannot be opened: 127.0.0.1:7545
at org.web3j.protocol.ipc.UnixDomainSocket.<init>(UnixDomainSocket.java:41)
at org.web3j.protocol.ipc.UnixDomainSocket.<init>(UnixDomainSocket.java:27)
at org.web3j.protocol.ipc.UnixIpcService.getIO(UnixIpcService.java:21)
at org.web3j.protocol.ipc.IpcService.performIO(IpcService.java:50)
at org.web3j.protocol.Service.send(Service.java:31)
at org.web3j.protocol.core.Request.send(Request.java:71)
at org.web3j.protocol.core.filters.BlockFilter.sendRequest(BlockFilter.java:24)
at org.web3j.protocol.core.filters.Filter.run(Filter.java:45)
at org.web3j.protocol.rx.JsonRpc2_0Rx.run(JsonRpc2_0Rx.java:73)
at org.web3j.protocol.rx.JsonRpc2_0Rx.lambda$ethBlockHashObservable$0(JsonRpc2_0Rx.java:46)
at rx.Observable.unsafeSubscribe(Observable.java:10142)
at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48)
at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.Observable.subscribe(Observable.java:10238)
at rx.Observable.subscribe(Observable.java:10205)
at rx.Observable.subscribe(Observable.java:10086)
at org.apache.camel.component.web3j.Web3jConsumer.doStart(Web3jConsumer.java:100)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3518)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:3835)
at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3771)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3691)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3455)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3309)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:202)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3093)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3089)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3112)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3089)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3026)
at org.apache.camel.main.Main.doStart(Main.java:129)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:168)
at com.optum.propel.commons.startup.AppInit.startMicroService(AppInit.java:141)
at com.optum.propel.commons.startup.AppInit.lambda$main$0(AppInit.java:81)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: No such file or directory
at jnr.unixsocket.UnixSocketChannel.doConnect(UnixSocketChannel.java:127)
at jnr.unixsocket.UnixSocketChannel.connect(UnixSocketChannel.java:136)
at jnr.unixsocket.UnixSocketChannel.open(UnixSocketChannel.java:68)
at org.web3j.protocol.ipc.UnixDomainSocket.<init>(UnixDomainSocket.java:35)
... 38 common frames omitted
{ "date_time":"2018-06-13 17:04:48,617", "thread":"[Thread-2]", "log_level":"INFO ", "class_name":"Web3jConsumer", "log_message":"Subscribed: org.apache.camel.component.web3j.Web3jConfiguration@1f7fe1b2" }
{ "date_time":"2018-06-13 17:04:48,617", "thread":"[Thread-2]", "log_level":"INFO ", "class_name":"DefaultCamelContext", "log_message":"Route: rsRoute started and consuming from: web3j://127.0.0.1:7545?operation=BLOCK_OBSERVABLE" }
我很困惑,因为它首先抛出一个错误,然后说它成功连接。此外,当我将操作更改为
ETH_GET_BLOCK_BY_HASH
时,会引发不受支持的操作异常。我想知道是否有人尝试使用此组件并看到了问题?
我正在使用的端点是:
web3j://127.0.0.1:7545?operation=BLOCK_OBSERVABLE
最佳答案
检查集成测试。
网址应为:http://127.0.0.1:7545
https://github.com/apache/camel/blob/master/components/camel-web3j/src/test/java/org/apache/camel/component/web3j/integration/Web3jProducerGanacheTest.java