im new to Spring reactive with r2dbc but i been facing this issue for 2 days, Im not able to fix.
What happpen was after the saving a data with a success response then it will keeps on Connection unexpectedly closed
application.properties
spring.r2dbc.url={value}
spring.r2dbc.username={value}
spring.r2dbc.password={value}
logging.level.root=DEBUG
DecodeContext-Result
2024-06-13T23:28:59.378+08:00 DEBUG 19632 --- [user-management-service] [actor-tcp-nio-3] i.a.r.m.m.server.MetadataDecodeContext : Respond a metadata bundle by filled-up
2024-06-13T23:28:59.378+08:00 DEBUG 19632 --- [user-management-service] [actor-tcp-nio-3] i.a.r.mysql.client.ReactorNettyClient : Response: SyntheticMetadataMessage{completed=false, messages=[DefinitionMetadataMessage{database='information_schema', table='SESSION_VARIABLES' (origin:'SESSION_VARIABLES'), column='Variable_name' (origin:'VARIABLE_NAME'), collationId=224, size=256, type=253, definitions=4097, decimals=0}, DefinitionMetadataMessage{database='information_schema', table='SESSION_VARIABLES' (origin:'SESSION_VARIABLES'), column='Value' (origin:'VARIABLE_VALUE'), collationId=224, size=16384, type=253, definitions=4097, decimals=0}], eof=null}
2024-06-13T23:28:59.378+08:00 DEBUG 19632 --- [user-management-service] [actor-tcp-nio-3] i.a.r.mysql.client.ReactorNettyClient : Response: RowMessage(encoded)
2024-06-13T23:28:59.379+08:00 DEBUG 19632 --- [user-management-service] [actor-tcp-nio-3] i.a.r.mysql.client.MessageDuplexCodec : Decode context change to DecodeContext-Command
2024-06-13T23:28:59.379+08:00 DEBUG 19632 --- [user-management-service] [actor-tcp-nio-3] i.a.r.mysql.client.ReactorNettyClient : Response: OkMessage{isEndOfRows=true, affectedRows=0, lastInsertId=0, serverStatuses=22, information='', systemVariables={}}
2024-06-13T23:28:59.379+08:00 DEBUG 19632 --- [user-management-service] [actor-tcp-nio-3] io.asyncer.r2dbc.mysql.InitFlow : Initializing connection 640808893 context: SessionState{level=IsolationLevel{sql='READ COMMITTED'}, product='MariaDB Server', timeZone=null, lockWaitTimeout=PT50S, lockWaitTimeoutSupported=true}
2024-06-13T23:28:59.379+08:00 DEBUG 19632 --- [user-management-service] [actor-tcp-nio-3] i.a.r2dbc.mysql.MySqlSimpleConnection : Batch is supported by server
2024-06-13T23:28:59.379+08:00 DEBUG 19632 --- [user-management-service] [actor-tcp-nio-3] reactor.pool.SimpleDequePool : warmed up extra resource 9/9
2024-06-13T23:29:06.138+08:00 WARN 19632 --- [user-management-service] [actor-tcp-nio-2] i.a.r.mysql.client.ReactorNettyClient : Connection unexpectedly closed
2024-06-13T23:29:06.138+08:00 ERROR 19632 --- [user-management-service] [actor-tcp-nio-2] reactor.core.publisher.Operators : Operator called default onErrorDropped
io.asyncer.r2dbc.mysql.client.MySqlConnectionClosedException: Connection unexpectedly closed
at io.asyncer.r2dbc.mysql.client.ClientExceptions.unexpectedClosed(ClientExceptions.java:32) ~[r2dbc-mysql-1.1.3.jar:1.1.3]
at io.asyncer.r2dbc.mysql.client.ReactorNettyClient.handleClose(ReactorNettyClient.java:320) ~[r2dbc-mysql-1.1.3.jar:1.1.3]
at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:265) ~[reactor-core-3.6.6.jar:3.6.6]
at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2231) ~[reactor-core-3.6.6.jar:3.6.6]
at reactor.core.publisher.FluxConcatMapNoPrefetch$FluxConcatMapNoPrefetchSubscriber.onComplete(FluxConcatMapNoPrefetch.java:241) ~[reactor-core-3.6.6.jar:3.6.6]
at reactor.core.publisher.SinkManyUnicast.checkTerminated(SinkManyUnicast.java:390) ~[reactor-core-3.6.6.jar:3.6.6]
at reactor.core.publisher.SinkManyUnicast.drainRegular(SinkManyUnicast.java:276) ~[reactor-core-3.6.6.jar:3.6.6]
at reactor.core.publisher.SinkManyUnicast.drain(SinkManyUnicast.java:365) ~[reactor-core-3.6.6.jar:3.6.6]
at reactor.core.publisher.SinkManyUnicast.tryEmitComplete(SinkManyUnicast.java:205) ~[reactor-core-3.6.6.jar:3.6.6]
at reactor.core.publisher.SinkManySerialized.tryEmitComplete(SinkManySerialized.java:64) ~[reactor-core-3.6.6.jar:3.6.6]
at reactor.core.publisher.InternalManySink.emitComplete(InternalManySink.java:68) ~[reactor-core-3.6.6.jar:3.6.6]
at io.asyncer.r2dbc.mysql.client.ReactorNettyClient.resumeError(ReactorNettyClient.java:291) ~[r2dbc-mysql-1.1.3.jar:1.1.3]
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94) ~[reactor-core-3.6.6.jar:3.6.6]
at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:222) ~[reactor-core-3.6.6.jar:3.6.6]
at reactor.netty.channel.FluxReceive.terminateReceiver(FluxReceive.java:480) ~[reactor-netty-core-1.1.19.jar:1.1.19]
at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:275) ~[reactor-netty-core-1.1.19.jar:1.1.19]
at reactor.netty.channel.FluxReceive.onInboundError(FluxReceive.java:468) ~[reactor-netty-core-1.1.19.jar:1.1.19]
at reactor.netty.channel.ChannelOperations.onInboundError(ChannelOperations.java:515) ~[reactor-netty-core-1.1.19.jar:1.1.19]
at reactor.netty.channel.ChannelOperationsHandler.exceptionCaught(ChannelOperationsHandler.java:145) ~[reactor-netty-core-1.1.19.jar:1.1.19]
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:346) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:325) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:317) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.handler.ssl.SslHandler.exceptionCaught(SslHandler.java:1204) ~[netty-handler-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:346) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:325) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:317) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.exceptionCaught(DefaultChannelPipeline.java:1374) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:346) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:325) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.DefaultChannelPipeline.fireExceptionCaught(DefaultChannelPipeline.java:906) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.handleReadException(AbstractNioByteChannel.java:125) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:177) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994) ~[netty-common-4.1.110.Final.jar:4.1.110.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.110.Final.jar:4.1.110.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.110.Final.jar:4.1.110.Final]
at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]
2024-06-13T23:29:06.138+08:00 ERROR 19632 --- [user-management-service] [actor-tcp-nio-2] i.a.r.mysql.client.ReactorNettyClient : Error: Connection reset
java.net.SocketException: Connection reset
at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:401) ~[na:na]
at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:434) ~[na:na]
at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:255) ~[netty-buffer-4.1.110.Final.jar:4.1.110.Final]
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132) ~[netty-buffer-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:356) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) ~[netty-transport-4.1.110.Final.jar:4.1.110.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994) ~[netty-common-4.1.110.Final.jar:4.1.110.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.110.Final.jar:4.1.110.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.110.Final.jar:4.1.110.Final]
at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.test</groupId>
<artifactId>wallet-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>service</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>oauth2-oidc-sdk</artifactId>
<version>6.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.asyncer</groupId>
<artifactId>r2dbc-mysql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
<finalName>test</finalName>
</build>
</project>