我收到ClosedChannelException错误,而发送邮件使用图API。我知道连接参数是正确的,因为它工作正常,当我尝试通过 Postman 。而且我的旧代码与图API 1.6.0工作正常。我试图升级到5.45.0。有人知道什么问题可能是什么吗?代码看起来正确的我。所以我也尝试改变依赖的jar版本,但是到目前为止没有任何效果。
我将以下代码与令牌凭证身份验证提供程序一起使用。https://github.com/microsoftgraph/microsoft-graph-docs/blob/main/api-reference/v1.0/includes/snippets/java/user-sendmail-with-attachment-java-snippets.md
所用版本:微软-图表-5.45.0天青-鉴别-1.7.3React器-芯-3.5.2React器-网状物-1.1.2网状物-全部-4.1.87.最终
com.microsoft.graph.core.ClientException: Error executing the request
at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:410)
at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:225)
at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:202)
at com.microsoft.graph.http.BaseRequest.send(BaseRequest.java:335)
at com.microsoft.graph.requests.UserSendMailRequest.post(UserSendMailRequest.java:54)
at com.test.GraphProducer.sendEmail(GraphProducer.java:151)
.....................
Caused by: java.io.IOException: java.util.concurrent.ExecutionException: com.microsoft.aad.msal4j.MsalClientException: reactor.core.Exceptions$ReactiveException: java.nio.channels.ClosedChannelException
at com.microsoft.graph.httpcore.AuthenticationHandler.intercept(AuthenticationHandler.java:67)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
.....................
at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:407)
... 52 more
Caused by: java.util.concurrent.ExecutionException: com.microsoft.aad.msal4j.MsalClientException: reactor.core.Exceptions$ReactiveException: java.nio.channels.ClosedChannelException
.....................
at com.microsoft.graph.httpcore.AuthenticationHandler.intercept(AuthenticationHandler.java:55)
... 60 more
Caused by: com.microsoft.aad.msal4j.MsalClientException: reactor.core.Exceptions$ReactiveException: java.nio.channels.ClosedChannelException
at com.microsoft.aad.msal4j.HttpHelper.executeHttpRequest(HttpHelper.java:53)
.....................
Caused by: reactor.core.Exceptions$ReactiveException: java.nio.channels.ClosedChannelException
at reactor.core.Exceptions.propagate(Exceptions.java:408)
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:97)
at reactor.core.publisher.Mono.block(Mono.java:1710)
at com.azure.core.http.HttpClient.sendSync(HttpClient.java:42)
.....................
at com.microsoft.aad.msal4j.HttpHelper.executeHttpRequestWithRetries(HttpHelper.java:96)
at com.microsoft.aad.msal4j.HttpHelper.executeHttpRequest(HttpHelper.java:49)
... 16 more
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
... 34 more
Suppressed: reactor.core.Exceptions$ReactiveException: java.nio.channels.ClosedChannelException
at reactor.core.Exceptions.propagate(Exceptions.java:408)
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:97)
at reactor.core.publisher.Mono.block(Mono.java:1710)
at com.azure.core.http.HttpClient.sendSync(HttpClient.java:42)
.....................
... 25 more
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
... 31 more
Caused by: java.nio.channels.ClosedChannelException
at io.netty.channel.AbstractChannel$AbstractUnsafe.newClosedChannelException(AbstractChannel.java:957)
.....................
at java.lang.Thread.run(Thread.java:745)
Suppressed: reactor.core.Exceptions$ReactiveException: java.nio.channels.ClosedChannelException
at reactor.core.Exceptions.propagate(Exceptions.java:408)
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:97)
at reactor.core.publisher.Mono.block(Mono.java:1710)
at com.azure.core.http.HttpClient.sendSync(HttpClient.java:42)
.....................
... 26 more
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
... 32 more
Caused by: java.nio.channels.ClosedChannelException
at io.netty.channel.AbstractChannel$AbstractUnsafe.newClosedChannelException(AbstractChannel.java:957)
.....................
at java.lang.Thread.run(Thread.java:745)
Suppressed: reactor.core.Exceptions$ReactiveException: java.nio.channels.ClosedChannelException
at reactor.core.Exceptions.propagate(Exceptions.java:408)
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:97)
at reactor.core.publisher.Mono.block(Mono.java:1710)
at com.azure.core.http.HttpClient.sendSync(HttpClient.java:42)
.....................
... 27 more
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
... 33 more
Caused by: java.nio.channels.ClosedChannelException
at io.netty.channel.AbstractChannel$AbstractUnsafe.newClosedChannelException(AbstractChannel.java:957)
at io.netty.channel.AbstractChannel$AbstractUnsafe.ensureOpen(AbstractChannel.java:976)
.....................
Caused by: java.nio.channels.ClosedChannelException
at io.netty.channel.AbstractChannel$AbstractUnsafe.newClosedChannelException(AbstractChannel.java:957)
at io.netty.channel.AbstractChannel$AbstractUnsafe.ensureOpen(AbstractChannel.java:976)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.connect(AbstractNioChannel.java:237)
at io.netty.channel.DefaultChannelPipeline$HeadContext.connect(DefaultChannelPipeline.java:1342)
at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:548)
at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:533)
at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:517)
at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:457)
at io.netty.channel.DefaultChannelPipeline.connect(DefaultChannelPipeline.java:942)
at io.netty.channel.AbstractChannel.connect(AbstractChannel.java:217)
at reactor.netty.transport.TransportConnector.lambda$doConnect$8(TransportConnector.java:240)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:745)
"2022年2月3日"更新:我尝试了下面的代码来检查令牌部分是否正常工作,发现它也抛出了同样的错误。
IAuthenticationProvider authProvider = new TokenCredentialAuthProvider(scopes, clientSecretCredential);
java.net.URL url = new java.net.URL("https://graph.microsoft.com/v1.0/users");
String token = authProvider.getAuthorizationTokenAsync(url).get();
1条答案
按热度按时间q9rjltbz1#
这是一个版本冲突问题。使用maven中的netty-all - 4.1.80.Final版本来修复它。