【发布时间】:2021-08-26 06:57:13
【问题描述】:
相关文档:
- 过滤器和Flowables http://docs.web3j.io/4.8.7/getting_started/pub_sub/
- 过滤器和事件http://docs.web3j.io/4.8.7/advanced/filters_and_events/
- 事件https://docs.soliditylang.org/en/develop/contracts.html#events
我正在尝试使用 web3j (v4.8.7) 实现读取区块链事件
/*
*/
@Slf4j
@Component
public class ContractEventSubscriber {
@Autowired
Web3j web3j;
@PostConstruct
public void init() {
log.info("Initializing...");
web3j.blockFlowable(false).subscribe(
block -> {
log.info("New block {}", block);
}, error -> {
log.error("Event error: {}", error, error); //!
});
log.info("Initialized.");
}
}
这个初始化已经失败了,
带有警告The filter has not been found 好像丢失或丢失了什么:
2021-08-26 14:40:23,723 [main] INFO com.xcompany.web3j.ContractEventSubscriber.init(43) -Initializing...
2021-08-26 14:40:25,134 [pool-2-thread-1] WARN org.web3j.protocol.core.filters.Filter.reinstallFilter(153) -The filter has not been found. Filter id: 330683721788227458774458119455366581270
Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
2021-08-26 14:40:25,420 [pool-2-thread-1] ERROR org.web3j.protocol.core.filters.Filter.lambda$run$0(97) -Error sending request
org.web3j.protocol.core.filters.FilterException: Error sending request
at org.web3j.protocol.core.filters.Filter.throwException(Filter.java:194)
at org.web3j.protocol.core.filters.Filter.run(Filter.java:104)
at org.web3j.protocol.core.filters.Filter.reinstallFilter(Filter.java:155)
at org.web3j.protocol.core.filters.Filter.pollFilter(Filter.java:137)
at org.web3j.protocol.core.filters.Filter.lambda$run$0(Filter.java:92)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
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: java.io.InterruptedIOException: interrupted
at okio.Timeout.throwIfReached(Timeout.kt:98)
at okio.OutputStreamSink.write(Okio.kt:53)
at okio.AsyncTimeout$sink$1.write(AsyncTimeout.kt:103)
at okio.RealBufferedSink.flush(RealBufferedSink.kt:247)
at okhttp3.internal.http1.Http1ExchangeCodec.finishRequest(Http1ExchangeCodec.kt:158)
at okhttp3.internal.connection.Exchange.finishRequest(Exchange.kt:90)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:76)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:37)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at com.huobi.pool.hedging.strategy.contract.config.RetryInterceptor.intercept(RetryInterceptor.java:25)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:194)
at okhttp3.RealCall.execute(RealCall.kt:67)
at org.web3j.protocol.http.HttpService.performIO(HttpService.java:165)
at org.web3j.protocol.Service.send(Service.java:48)
at org.web3j.protocol.core.Request.send(Request.java:87)
at org.web3j.protocol.core.filters.BlockFilter.sendRequest(BlockFilter.java:34)
at org.web3j.protocol.core.filters.Filter.run(Filter.java:59)
... 10 common frames omitted
【问题讨论】: