阻塞的顶点线程
Blocked vertx threads
我必须学会使用以下方法开发微服务:
- Java 8
- 顶点 3.9
- 行家 3.6
- MongoDB 超过 Docker 19.03.1
作为 IDE 我正在使用 Intellij
我正在处理的代码是这样的:
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import io.vertx.core.json.Json;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.mongo.MongoClient;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.BodyHandler;
public class MainVerticle extends AbstractVerticle {
MongoClient mongoSharedClient = null;
private Future<Void> prepareDatabase(){
Promise<Void> promises = Promise.promise();
JsonObject config = Vertx.currentContext().config();
String uri = config.getString("mongo_uri");
if(uri == null){
uri = "mongodb://localhost:27017";
}
String database = config.getString("mongo_db");
if (database == null){
database = "test";
}
JsonObject configMongo = new JsonObject();
configMongo.put("connection_string", uri);
configMongo.put("db_name", database);
mongoSharedClient = MongoClient.create(vertx, configMongo);
if(mongoSharedClient != null){
promises.complete();
}else {
promises.fail("Error in Database");
}
return promises.future();
}
@Override
public void start(Promise<Void> startFuture) throws Exception {
prepareDatabase().compose(as-> HttpServer()).onComplete(asyn->{
if(asyn.succeeded()){
startFuture.complete();
}else {
startFuture.fail("Error");
}
});
}
private Future<Void> HttpServer(){
Promise<Void> promises = Promise.promise();
HttpServer server = vertx.createHttpServer();
Router router = Router.router(vertx);
router.get("/test/").handler(this::pruebaRuta);
router.post("/create/").handler(this::createPrueba);
router.post().handler(BodyHandler.create());
server.requestHandler(router).listen(9090, ar -> {
if(ar.succeeded()){
promises.complete();
}else {
promises.fail(ar.cause());
}
});
return promises.future();
}
private void createPrueba(RoutingContext routingContext) {
JsonObject data = routingContext.getBodyAsJson();
mongoSharedClient.insert("User", data, result -> {
if(result.succeeded()){
routingContext.response().setStatusCode(200).putHeader("Content-Type", "text/html").end("Operation Successful");
}else {
routingContext.response().setStatusCode(400).putHeader("Content-Type", "text/html").end(result.cause().getMessage());
}
});
routingContext.response().setStatusCode(200).putHeader("Content-Type", "Application/Json; charset=utf-8").end(Json.encodePrettily(data));
}
private void pruebaRuta(RoutingContext routingContext) {
routingContext.response().setStatusCode(200).putHeader("Content-Type", "text/html").end("Success Execute!");
}
}
目前我只想用邮递员做小测试,问题是当我 运行 项目时,我得到以下信息:
Connected to the target VM, address: '127.0.0.1:51951', transport: 'socket'
18:36:02.095 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
18:36:02.108 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple
18:36:02.108 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.targetRecords: 4
18:36:02.393 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024
18:36:02.393 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.maxSize: 4096
18:36:02.578 [main] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 8
18:36:02.824 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
18:36:02.824 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
18:36:02.874 [main] DEBUG io.netty.util.internal.PlatformDependent - Platform: Windows
18:36:02.878 [main] DEBUG io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false
18:36:02.880 [main] DEBUG io.netty.util.internal.PlatformDependent0 - Java version: 8
18:36:02.883 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
18:36:02.886 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
18:36:02.888 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
18:36:02.889 [main] DEBUG io.netty.util.internal.PlatformDependent0 - direct buffer constructor: available
18:36:02.892 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true
18:36:02.892 [main] DEBUG io.netty.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable prior to Java9
18:36:02.892 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, int): available
18:36:02.892 [main] DEBUG io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available
18:36:02.894 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: C:\Users\kathy\AppData\Local\Temp (java.io.tmpdir)
18:36:02.894 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
18:36:02.899 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: 934281216 bytes
18:36:02.899 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1
18:36:02.902 [main] DEBUG io.netty.util.internal.CleanerJava6 - java.nio.ByteBuffer.cleaner(): available
18:36:02.902 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
18:36:02.924 [main] DEBUG io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available
18:36:06.345 [main] DEBUG io.netty.resolver.dns.DefaultDnsServerAddressStreamProvider - Default DNS servers: [/1.1.1.1:53, /8.8.8.8:53] (sun.net.dns.ResolverConfiguration)
18:36:08.487 [vert.x-eventloop-thread-0] INFO org.mongodb.driver.cluster - Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
18:36:08.619 [vert.x-eventloop-thread-0] DEBUG org.mongodb.driver.cluster - Updating cluster description to {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]
jul 07, 2020 6:36:09 PM io.vertx.core.impl.BlockedThreadChecker
ADVERTENCIA: Thread Thread[vert.x-eventloop-thread-0,5,main]=Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 2459 ms, time limit is 2000 ms
18:36:10.012 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 8
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 8
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.tinyCacheSize: 512
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
18:36:10.014 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192
18:36:10.014 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimIntervalMillis: 0
18:36:10.014 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.useCacheForAllThreads: true
18:36:10.014 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedByteBuffersPerChunk: 1023
18:36:10.327 [vert.x-eventloop-thread-0] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false
18:36:10.328 [vert.x-eventloop-thread-0] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false
jul 07, 2020 6:36:10 PM io.vertx.core.impl.BlockedThreadChecker
ADVERTENCIA: Thread Thread[vert.x-eventloop-thread-0,5,main]=Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 3485 ms, time limit is 2000 ms
18:36:11.188 [vert.x-eventloop-thread-0] DEBUG io.netty.util.NetUtil - Loopback interface: lo (Software Loopback Interface 1, 127.0.0.1)
18:36:11.189 [vert.x-eventloop-thread-0] DEBUG io.netty.util.NetUtil - Failed to get SOMAXCONN from sysctl and file \proc\sys\net\core\somaxconn. Default: 200
jul 07, 2020 6:36:11 PM io.vertx.core.impl.BlockedThreadChecker
ADVERTENCIA: Thread Thread[vert.x-eventloop-thread-0,5,main]=Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 4489 ms, time limit is 2000 ms
18:36:12.550 [vert.x-eventloop-thread-0] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.processId: 6252 (auto-detected)
jul 07, 2020 6:36:12 PM io.vertx.core.impl.BlockedThreadChecker
ADVERTENCIA: Thread Thread[vert.x-eventloop-thread-0,5,main]=Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 5489 ms, time limit is 2000 ms
io.vertx.core.VertxException: Thread blocked
at java.net.NetworkInterface.getAll(Native Method)
at java.net.NetworkInterface.getNetworkInterfaces(NetworkInterface.java:355)
at io.netty.util.internal.MacAddressUtil.bestAvailableMac(MacAddressUtil.java:55)
at io.netty.util.internal.MacAddressUtil.defaultMachineId(MacAddressUtil.java:138)
at io.netty.channel.DefaultChannelId.<clinit>(DefaultChannelId.java:99)
at io.netty.channel.AbstractChannel.newId(AbstractChannel.java:101)
at io.netty.channel.AbstractChannel.<init>(AbstractChannel.java:73)
at io.netty.channel.nio.AbstractNioChannel.<init>(AbstractNioChannel.java:80)
at io.netty.channel.nio.AbstractNioMessageChannel.<init>(AbstractNioMessageChannel.java:42)
at io.netty.channel.socket.nio.NioDatagramChannel.<init>(NioDatagramChannel.java:150)
at io.netty.channel.socket.nio.NioDatagramChannel.<init>(NioDatagramChannel.java:118)
at io.vertx.core.net.impl.transport.Transport.datagramChannel(Transport.java:162)
at io.vertx.core.impl.resolver.DnsResolverProvider.lambda$newResolver[=11=](DnsResolverProvider.java:136)
at io.vertx.core.impl.resolver.DnsResolverProvider$$Lambda/1292567456.newChannel(Unknown Source)
at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:310)
at io.netty.bootstrap.AbstractBootstrap.register(AbstractBootstrap.java:227)
at io.netty.resolver.dns.DnsNameResolver.<init>(DnsNameResolver.java:451)
at io.netty.resolver.dns.DnsNameResolverBuilder.build(DnsNameResolverBuilder.java:473)
at io.vertx.core.impl.resolver.DnsResolverProvider.newNameResolver(DnsResolverProvider.java:186)
at io.netty.resolver.dns.DnsAddressResolverGroup.newResolver(DnsAddressResolverGroup.java:91)
at io.netty.resolver.dns.DnsAddressResolverGroup.newResolver(DnsAddressResolverGroup.java:76)
at io.netty.resolver.AddressResolverGroup.getResolver(AddressResolverGroup.java:70)
at io.vertx.core.impl.resolver.DnsResolverProvider.newResolver(DnsResolverProvider.java:190)
at io.netty.resolver.AddressResolverGroup.getResolver(AddressResolverGroup.java:70)
at io.vertx.core.impl.AddressResolver.resolveHostname(AddressResolver.java:82)
at io.vertx.core.impl.VertxImpl.resolveAddress(VertxImpl.java:810)
at io.vertx.core.net.impl.AsyncResolveConnectHelper.doBind(AsyncResolveConnectHelper.java:56)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:253)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:188)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:184)
at com.lakatuna.com.MainVerticle.HttpServer(MainVerticle.java:75)
at com.lakatuna.com.MainVerticle.lambda$start[=11=](MainVerticle.java:56)
at com.lakatuna.com.MainVerticle$$Lambda/752448968.apply(Unknown Source)
at io.vertx.core.Future.lambda$compose(Future.java:363)
at io.vertx.core.Future$$Lambda/767632927.handle(Unknown Source)
at io.vertx.core.impl.FutureImpl.dispatch(FutureImpl.java:105)
at io.vertx.core.impl.FutureImpl.onComplete(FutureImpl.java:83)
at io.vertx.core.Future.compose(Future.java:359)
at io.vertx.core.Future.compose(Future.java:331)
at com.lakatuna.com.MainVerticle.start(MainVerticle.java:56)
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy(DeploymentManager.java:556)
at io.vertx.core.impl.DeploymentManager$$Lambda/726379593.handle(Unknown Source)
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:369)
at io.vertx.core.impl.EventLoopContext.lambda$executeAsync[=11=](EventLoopContext.java:38)
at io.vertx.core.impl.EventLoopContext$$Lambda/1212772528.run(Unknown Source)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java)
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.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
18:36:13.149 [vert.x-eventloop-thread-0] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.machineId: 9c:ad:97:ff:fe:8b:00:df (auto-detected)
18:36:13.342 [cluster-ClusterId{value='5f0506e849515074214c3f60', description='null'}-localhost:27017] DEBUG org.mongodb.driver.connection - Closing connection connectionId{localValue:1}
18:36:13.602 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled
18:36:13.602 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 0
18:36:13.602 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384
18:36:13.635 [cluster-ClusterId{value='5f0506e849515074214c3f60', description='null'}-localhost:27017] INFO org.mongodb.driver.cluster - Exception in monitor thread while connecting to server localhost:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.internal.connection.AsynchronousSocketChannelStream$OpenCompletionHandler.failed(AsynchronousSocketChannelStream.java:117)
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:128)
at sun.nio.ch.Invoker.invokeDirect(Invoker.java:157)
at sun.nio.ch.Invoker.invoke(Invoker.java:185)
at sun.nio.ch.Invoker.invoke(Invoker.java:297)
at sun.nio.ch.WindowsAsynchronousSocketChannelImpl$ConnectTask.failed(WindowsAsynchronousSocketChannelImpl.java:302)
at sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:399)
at sun.nio.ch.AsynchronousChannelGroupImpl.run(AsynchronousChannelGroupImpl.java:112)
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.IOException: El equipo remoto rechazó la conexión de red.
at sun.nio.ch.Iocp.translateErrorToIOException(Iocp.java:309)
at sun.nio.ch.Iocp.access0(Iocp.java:46)
... 5 common frames omitted
jul 07, 2020 6:36:13 PM io.vertx.core.impl.BlockedThreadChecker
ADVERTENCIA: Thread Thread[vert.x-eventloop-thread-0,5,main]=Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 6490 ms, time limit is 2000 ms
io.vertx.core.VertxException: Thread blocked
at java.net.DatagramSocket.run(DatagramSocket.java:312)
at java.net.DatagramSocket.run(DatagramSocket.java:309)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.DatagramSocket.checkOldImpl(DatagramSocket.java:308)
at java.net.DatagramSocket.<init>(DatagramSocket.java:211)
at sun.nio.ch.DatagramSocketAdaptor.<init>(DatagramSocketAdaptor.java:57)
at sun.nio.ch.DatagramSocketAdaptor.create(DatagramSocketAdaptor.java:63)
at sun.nio.ch.DatagramChannelImpl.socket(DatagramChannelImpl.java:173)
at io.netty.channel.socket.nio.NioDatagramChannelConfig.<init>(NioDatagramChannelConfig.java:117)
at io.netty.channel.socket.nio.NioDatagramChannel.<init>(NioDatagramChannel.java:151)
at io.netty.channel.socket.nio.NioDatagramChannel.<init>(NioDatagramChannel.java:118)
at io.vertx.core.net.impl.transport.Transport.datagramChannel(Transport.java:162)
at io.vertx.core.impl.resolver.DnsResolverProvider.lambda$newResolver[=11=](DnsResolverProvider.java:136)
at io.vertx.core.impl.resolver.DnsResolverProvider$$Lambda/1292567456.newChannel(Unknown Source)
at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:310)
at io.netty.bootstrap.AbstractBootstrap.register(AbstractBootstrap.java:227)
at io.netty.resolver.dns.DnsNameResolver.<init>(DnsNameResolver.java:451)
at io.netty.resolver.dns.DnsNameResolverBuilder.build(DnsNameResolverBuilder.java:473)
at io.vertx.core.impl.resolver.DnsResolverProvider.newNameResolver(DnsResolverProvider.java:186)
at io.netty.resolver.dns.DnsAddressResolverGroup.newResolver(DnsAddressResolverGroup.java:91)
at io.netty.resolver.dns.DnsAddressResolverGroup.newResolver(DnsAddressResolverGroup.java:76)
at io.netty.resolver.AddressResolverGroup.getResolver(AddressResolverGroup.java:70)
at io.vertx.core.impl.resolver.DnsResolverProvider.newResolver(DnsResolverProvider.java:190)
at io.netty.resolver.AddressResolverGroup.getResolver(AddressResolverGroup.java:70)
at io.vertx.core.impl.AddressResolver.resolveHostname(AddressResolver.java:82)
at io.vertx.core.impl.VertxImpl.resolveAddress(VertxImpl.java:810)
at io.vertx.core.net.impl.AsyncResolveConnectHelper.doBind(AsyncResolveConnectHelper.java:56)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:253)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:188)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:184)
at com.lakatuna.com.MainVerticle.HttpServer(MainVerticle.java:75)
at com.lakatuna.com.MainVerticle.lambda$start[=11=](MainVerticle.java:56)
at com.lakatuna.com.MainVerticle$$Lambda/752448968.apply(Unknown Source)
at io.vertx.core.Future.lambda$compose(Future.java:363)
at io.vertx.core.Future$$Lambda/767632927.handle(Unknown Source)
at io.vertx.core.impl.FutureImpl.dispatch(FutureImpl.java:105)
at io.vertx.core.impl.FutureImpl.onComplete(FutureImpl.java:83)
at io.vertx.core.Future.compose(Future.java:359)
at io.vertx.core.Future.compose(Future.java:331)
at com.lakatuna.com.MainVerticle.start(MainVerticle.java:56)
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy(DeploymentManager.java:556)
at io.vertx.core.impl.DeploymentManager$$Lambda/726379593.handle(Unknown Source)
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:369)
at io.vertx.core.impl.EventLoopContext.lambda$executeAsync[=11=](EventLoopContext.java:38)
at io.vertx.core.impl.EventLoopContext$$Lambda/1212772528.run(Unknown Source)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java)
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.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
18:36:13.660 [cluster-ClusterId{value='5f0506e849515074214c3f60', description='null'}-localhost:27017] DEBUG org.mongodb.driver.cluster - Updating cluster description to {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.io.IOException: El equipo remoto rechazó la conexión de red.
}}]
Vertx 线程被阻塞。
在邮递员中我尝试测试路由 localhost:9090/create/ 并且它 returns 错误 500
我知道问题很长,但说真的我不知道该怎么做,我一直在寻找解决方案,但事实是我真的不明白我的错误是什么或发生了什么,我需要你的帮助。非常感谢
如果您查看中间的堆栈跟踪,它会报告它试图连接到 Mongo 数据库的主机拒绝了连接。确保它是可达的。
我敢打赌,您看到的 500 错误是由于您尝试使用 mongo 客户端而导致的空指针异常,即使它未能初始化并且从未分配变量。
第一个和第三个堆栈跟踪抱怨在启动服务器时绑定到端口花费的时间太长。 This might be an issue in the underlying netty library.
我必须学会使用以下方法开发微服务:
- Java 8
- 顶点 3.9
- 行家 3.6
- MongoDB 超过 Docker 19.03.1
作为 IDE 我正在使用 Intellij
我正在处理的代码是这样的:
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import io.vertx.core.json.Json;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.mongo.MongoClient;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.BodyHandler;
public class MainVerticle extends AbstractVerticle {
MongoClient mongoSharedClient = null;
private Future<Void> prepareDatabase(){
Promise<Void> promises = Promise.promise();
JsonObject config = Vertx.currentContext().config();
String uri = config.getString("mongo_uri");
if(uri == null){
uri = "mongodb://localhost:27017";
}
String database = config.getString("mongo_db");
if (database == null){
database = "test";
}
JsonObject configMongo = new JsonObject();
configMongo.put("connection_string", uri);
configMongo.put("db_name", database);
mongoSharedClient = MongoClient.create(vertx, configMongo);
if(mongoSharedClient != null){
promises.complete();
}else {
promises.fail("Error in Database");
}
return promises.future();
}
@Override
public void start(Promise<Void> startFuture) throws Exception {
prepareDatabase().compose(as-> HttpServer()).onComplete(asyn->{
if(asyn.succeeded()){
startFuture.complete();
}else {
startFuture.fail("Error");
}
});
}
private Future<Void> HttpServer(){
Promise<Void> promises = Promise.promise();
HttpServer server = vertx.createHttpServer();
Router router = Router.router(vertx);
router.get("/test/").handler(this::pruebaRuta);
router.post("/create/").handler(this::createPrueba);
router.post().handler(BodyHandler.create());
server.requestHandler(router).listen(9090, ar -> {
if(ar.succeeded()){
promises.complete();
}else {
promises.fail(ar.cause());
}
});
return promises.future();
}
private void createPrueba(RoutingContext routingContext) {
JsonObject data = routingContext.getBodyAsJson();
mongoSharedClient.insert("User", data, result -> {
if(result.succeeded()){
routingContext.response().setStatusCode(200).putHeader("Content-Type", "text/html").end("Operation Successful");
}else {
routingContext.response().setStatusCode(400).putHeader("Content-Type", "text/html").end(result.cause().getMessage());
}
});
routingContext.response().setStatusCode(200).putHeader("Content-Type", "Application/Json; charset=utf-8").end(Json.encodePrettily(data));
}
private void pruebaRuta(RoutingContext routingContext) {
routingContext.response().setStatusCode(200).putHeader("Content-Type", "text/html").end("Success Execute!");
}
}
目前我只想用邮递员做小测试,问题是当我 运行 项目时,我得到以下信息:
Connected to the target VM, address: '127.0.0.1:51951', transport: 'socket'
18:36:02.095 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
18:36:02.108 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple
18:36:02.108 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.targetRecords: 4
18:36:02.393 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024
18:36:02.393 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.maxSize: 4096
18:36:02.578 [main] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 8
18:36:02.824 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
18:36:02.824 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
18:36:02.874 [main] DEBUG io.netty.util.internal.PlatformDependent - Platform: Windows
18:36:02.878 [main] DEBUG io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false
18:36:02.880 [main] DEBUG io.netty.util.internal.PlatformDependent0 - Java version: 8
18:36:02.883 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
18:36:02.886 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
18:36:02.888 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
18:36:02.889 [main] DEBUG io.netty.util.internal.PlatformDependent0 - direct buffer constructor: available
18:36:02.892 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true
18:36:02.892 [main] DEBUG io.netty.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable prior to Java9
18:36:02.892 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, int): available
18:36:02.892 [main] DEBUG io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available
18:36:02.894 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: C:\Users\kathy\AppData\Local\Temp (java.io.tmpdir)
18:36:02.894 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
18:36:02.899 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: 934281216 bytes
18:36:02.899 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1
18:36:02.902 [main] DEBUG io.netty.util.internal.CleanerJava6 - java.nio.ByteBuffer.cleaner(): available
18:36:02.902 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
18:36:02.924 [main] DEBUG io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available
18:36:06.345 [main] DEBUG io.netty.resolver.dns.DefaultDnsServerAddressStreamProvider - Default DNS servers: [/1.1.1.1:53, /8.8.8.8:53] (sun.net.dns.ResolverConfiguration)
18:36:08.487 [vert.x-eventloop-thread-0] INFO org.mongodb.driver.cluster - Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
18:36:08.619 [vert.x-eventloop-thread-0] DEBUG org.mongodb.driver.cluster - Updating cluster description to {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]
jul 07, 2020 6:36:09 PM io.vertx.core.impl.BlockedThreadChecker
ADVERTENCIA: Thread Thread[vert.x-eventloop-thread-0,5,main]=Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 2459 ms, time limit is 2000 ms
18:36:10.012 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 8
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 8
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.tinyCacheSize: 512
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64
18:36:10.013 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
18:36:10.014 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192
18:36:10.014 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimIntervalMillis: 0
18:36:10.014 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.useCacheForAllThreads: true
18:36:10.014 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedByteBuffersPerChunk: 1023
18:36:10.327 [vert.x-eventloop-thread-0] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false
18:36:10.328 [vert.x-eventloop-thread-0] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false
jul 07, 2020 6:36:10 PM io.vertx.core.impl.BlockedThreadChecker
ADVERTENCIA: Thread Thread[vert.x-eventloop-thread-0,5,main]=Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 3485 ms, time limit is 2000 ms
18:36:11.188 [vert.x-eventloop-thread-0] DEBUG io.netty.util.NetUtil - Loopback interface: lo (Software Loopback Interface 1, 127.0.0.1)
18:36:11.189 [vert.x-eventloop-thread-0] DEBUG io.netty.util.NetUtil - Failed to get SOMAXCONN from sysctl and file \proc\sys\net\core\somaxconn. Default: 200
jul 07, 2020 6:36:11 PM io.vertx.core.impl.BlockedThreadChecker
ADVERTENCIA: Thread Thread[vert.x-eventloop-thread-0,5,main]=Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 4489 ms, time limit is 2000 ms
18:36:12.550 [vert.x-eventloop-thread-0] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.processId: 6252 (auto-detected)
jul 07, 2020 6:36:12 PM io.vertx.core.impl.BlockedThreadChecker
ADVERTENCIA: Thread Thread[vert.x-eventloop-thread-0,5,main]=Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 5489 ms, time limit is 2000 ms
io.vertx.core.VertxException: Thread blocked
at java.net.NetworkInterface.getAll(Native Method)
at java.net.NetworkInterface.getNetworkInterfaces(NetworkInterface.java:355)
at io.netty.util.internal.MacAddressUtil.bestAvailableMac(MacAddressUtil.java:55)
at io.netty.util.internal.MacAddressUtil.defaultMachineId(MacAddressUtil.java:138)
at io.netty.channel.DefaultChannelId.<clinit>(DefaultChannelId.java:99)
at io.netty.channel.AbstractChannel.newId(AbstractChannel.java:101)
at io.netty.channel.AbstractChannel.<init>(AbstractChannel.java:73)
at io.netty.channel.nio.AbstractNioChannel.<init>(AbstractNioChannel.java:80)
at io.netty.channel.nio.AbstractNioMessageChannel.<init>(AbstractNioMessageChannel.java:42)
at io.netty.channel.socket.nio.NioDatagramChannel.<init>(NioDatagramChannel.java:150)
at io.netty.channel.socket.nio.NioDatagramChannel.<init>(NioDatagramChannel.java:118)
at io.vertx.core.net.impl.transport.Transport.datagramChannel(Transport.java:162)
at io.vertx.core.impl.resolver.DnsResolverProvider.lambda$newResolver[=11=](DnsResolverProvider.java:136)
at io.vertx.core.impl.resolver.DnsResolverProvider$$Lambda/1292567456.newChannel(Unknown Source)
at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:310)
at io.netty.bootstrap.AbstractBootstrap.register(AbstractBootstrap.java:227)
at io.netty.resolver.dns.DnsNameResolver.<init>(DnsNameResolver.java:451)
at io.netty.resolver.dns.DnsNameResolverBuilder.build(DnsNameResolverBuilder.java:473)
at io.vertx.core.impl.resolver.DnsResolverProvider.newNameResolver(DnsResolverProvider.java:186)
at io.netty.resolver.dns.DnsAddressResolverGroup.newResolver(DnsAddressResolverGroup.java:91)
at io.netty.resolver.dns.DnsAddressResolverGroup.newResolver(DnsAddressResolverGroup.java:76)
at io.netty.resolver.AddressResolverGroup.getResolver(AddressResolverGroup.java:70)
at io.vertx.core.impl.resolver.DnsResolverProvider.newResolver(DnsResolverProvider.java:190)
at io.netty.resolver.AddressResolverGroup.getResolver(AddressResolverGroup.java:70)
at io.vertx.core.impl.AddressResolver.resolveHostname(AddressResolver.java:82)
at io.vertx.core.impl.VertxImpl.resolveAddress(VertxImpl.java:810)
at io.vertx.core.net.impl.AsyncResolveConnectHelper.doBind(AsyncResolveConnectHelper.java:56)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:253)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:188)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:184)
at com.lakatuna.com.MainVerticle.HttpServer(MainVerticle.java:75)
at com.lakatuna.com.MainVerticle.lambda$start[=11=](MainVerticle.java:56)
at com.lakatuna.com.MainVerticle$$Lambda/752448968.apply(Unknown Source)
at io.vertx.core.Future.lambda$compose(Future.java:363)
at io.vertx.core.Future$$Lambda/767632927.handle(Unknown Source)
at io.vertx.core.impl.FutureImpl.dispatch(FutureImpl.java:105)
at io.vertx.core.impl.FutureImpl.onComplete(FutureImpl.java:83)
at io.vertx.core.Future.compose(Future.java:359)
at io.vertx.core.Future.compose(Future.java:331)
at com.lakatuna.com.MainVerticle.start(MainVerticle.java:56)
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy(DeploymentManager.java:556)
at io.vertx.core.impl.DeploymentManager$$Lambda/726379593.handle(Unknown Source)
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:369)
at io.vertx.core.impl.EventLoopContext.lambda$executeAsync[=11=](EventLoopContext.java:38)
at io.vertx.core.impl.EventLoopContext$$Lambda/1212772528.run(Unknown Source)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java)
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.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
18:36:13.149 [vert.x-eventloop-thread-0] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.machineId: 9c:ad:97:ff:fe:8b:00:df (auto-detected)
18:36:13.342 [cluster-ClusterId{value='5f0506e849515074214c3f60', description='null'}-localhost:27017] DEBUG org.mongodb.driver.connection - Closing connection connectionId{localValue:1}
18:36:13.602 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled
18:36:13.602 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 0
18:36:13.602 [vert.x-eventloop-thread-0] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384
18:36:13.635 [cluster-ClusterId{value='5f0506e849515074214c3f60', description='null'}-localhost:27017] INFO org.mongodb.driver.cluster - Exception in monitor thread while connecting to server localhost:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.internal.connection.AsynchronousSocketChannelStream$OpenCompletionHandler.failed(AsynchronousSocketChannelStream.java:117)
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:128)
at sun.nio.ch.Invoker.invokeDirect(Invoker.java:157)
at sun.nio.ch.Invoker.invoke(Invoker.java:185)
at sun.nio.ch.Invoker.invoke(Invoker.java:297)
at sun.nio.ch.WindowsAsynchronousSocketChannelImpl$ConnectTask.failed(WindowsAsynchronousSocketChannelImpl.java:302)
at sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:399)
at sun.nio.ch.AsynchronousChannelGroupImpl.run(AsynchronousChannelGroupImpl.java:112)
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.IOException: El equipo remoto rechazó la conexión de red.
at sun.nio.ch.Iocp.translateErrorToIOException(Iocp.java:309)
at sun.nio.ch.Iocp.access0(Iocp.java:46)
... 5 common frames omitted
jul 07, 2020 6:36:13 PM io.vertx.core.impl.BlockedThreadChecker
ADVERTENCIA: Thread Thread[vert.x-eventloop-thread-0,5,main]=Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 6490 ms, time limit is 2000 ms
io.vertx.core.VertxException: Thread blocked
at java.net.DatagramSocket.run(DatagramSocket.java:312)
at java.net.DatagramSocket.run(DatagramSocket.java:309)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.DatagramSocket.checkOldImpl(DatagramSocket.java:308)
at java.net.DatagramSocket.<init>(DatagramSocket.java:211)
at sun.nio.ch.DatagramSocketAdaptor.<init>(DatagramSocketAdaptor.java:57)
at sun.nio.ch.DatagramSocketAdaptor.create(DatagramSocketAdaptor.java:63)
at sun.nio.ch.DatagramChannelImpl.socket(DatagramChannelImpl.java:173)
at io.netty.channel.socket.nio.NioDatagramChannelConfig.<init>(NioDatagramChannelConfig.java:117)
at io.netty.channel.socket.nio.NioDatagramChannel.<init>(NioDatagramChannel.java:151)
at io.netty.channel.socket.nio.NioDatagramChannel.<init>(NioDatagramChannel.java:118)
at io.vertx.core.net.impl.transport.Transport.datagramChannel(Transport.java:162)
at io.vertx.core.impl.resolver.DnsResolverProvider.lambda$newResolver[=11=](DnsResolverProvider.java:136)
at io.vertx.core.impl.resolver.DnsResolverProvider$$Lambda/1292567456.newChannel(Unknown Source)
at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:310)
at io.netty.bootstrap.AbstractBootstrap.register(AbstractBootstrap.java:227)
at io.netty.resolver.dns.DnsNameResolver.<init>(DnsNameResolver.java:451)
at io.netty.resolver.dns.DnsNameResolverBuilder.build(DnsNameResolverBuilder.java:473)
at io.vertx.core.impl.resolver.DnsResolverProvider.newNameResolver(DnsResolverProvider.java:186)
at io.netty.resolver.dns.DnsAddressResolverGroup.newResolver(DnsAddressResolverGroup.java:91)
at io.netty.resolver.dns.DnsAddressResolverGroup.newResolver(DnsAddressResolverGroup.java:76)
at io.netty.resolver.AddressResolverGroup.getResolver(AddressResolverGroup.java:70)
at io.vertx.core.impl.resolver.DnsResolverProvider.newResolver(DnsResolverProvider.java:190)
at io.netty.resolver.AddressResolverGroup.getResolver(AddressResolverGroup.java:70)
at io.vertx.core.impl.AddressResolver.resolveHostname(AddressResolver.java:82)
at io.vertx.core.impl.VertxImpl.resolveAddress(VertxImpl.java:810)
at io.vertx.core.net.impl.AsyncResolveConnectHelper.doBind(AsyncResolveConnectHelper.java:56)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:253)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:188)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:184)
at com.lakatuna.com.MainVerticle.HttpServer(MainVerticle.java:75)
at com.lakatuna.com.MainVerticle.lambda$start[=11=](MainVerticle.java:56)
at com.lakatuna.com.MainVerticle$$Lambda/752448968.apply(Unknown Source)
at io.vertx.core.Future.lambda$compose(Future.java:363)
at io.vertx.core.Future$$Lambda/767632927.handle(Unknown Source)
at io.vertx.core.impl.FutureImpl.dispatch(FutureImpl.java:105)
at io.vertx.core.impl.FutureImpl.onComplete(FutureImpl.java:83)
at io.vertx.core.Future.compose(Future.java:359)
at io.vertx.core.Future.compose(Future.java:331)
at com.lakatuna.com.MainVerticle.start(MainVerticle.java:56)
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy(DeploymentManager.java:556)
at io.vertx.core.impl.DeploymentManager$$Lambda/726379593.handle(Unknown Source)
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:369)
at io.vertx.core.impl.EventLoopContext.lambda$executeAsync[=11=](EventLoopContext.java:38)
at io.vertx.core.impl.EventLoopContext$$Lambda/1212772528.run(Unknown Source)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java)
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.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
18:36:13.660 [cluster-ClusterId{value='5f0506e849515074214c3f60', description='null'}-localhost:27017] DEBUG org.mongodb.driver.cluster - Updating cluster description to {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.io.IOException: El equipo remoto rechazó la conexión de red.
}}]
Vertx 线程被阻塞。
在邮递员中我尝试测试路由 localhost:9090/create/ 并且它 returns 错误 500
我知道问题很长,但说真的我不知道该怎么做,我一直在寻找解决方案,但事实是我真的不明白我的错误是什么或发生了什么,我需要你的帮助。非常感谢
如果您查看中间的堆栈跟踪,它会报告它试图连接到 Mongo 数据库的主机拒绝了连接。确保它是可达的。
我敢打赌,您看到的 500 错误是由于您尝试使用 mongo 客户端而导致的空指针异常,即使它未能初始化并且从未分配变量。
第一个和第三个堆栈跟踪抱怨在启动服务器时绑定到端口花费的时间太长。 This might be an issue in the underlying netty library.