Plenty of "IOExceptions: Connection reset by peer" after upgrading to "faunadb-java:4.0.1"

Hi!
Can someone help me understand this problem?
Since 1 month ago, after we upgraded to ‘faunadb-java:4.0.1’, we started receiving a lot of these exceptions in our error tracking system:

com.faunadb.common.Connection - Request: POST https://db.fauna.com: jdk.internal.net.http.RequestPublishers$ByteArrayPublisher@27372fb4. Failed: java.io.IOException: HTTP/1.1 header parser received no bytes
java.util.concurrent.CompletionException: java.io.IOException: HTTP/1.1 header parser received no bytes
at java.base/java.util.concurrent.CompletableFuture.encodeRelay(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.completeRelay(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source)
at java.net.http/jdk.internal.net.http.Http1Response.onReadError(Unknown Source)
at java.net.http/jdk.internal.net.http.Http1Response$HeadersReader.onReadError(Unknown Source)
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.checkForErrors(Unknown Source)
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.flush(Unknown Source)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(Unknown Source)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(Unknown Source)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: HTTP/1.1 header parser received no bytes
at java.net.http/jdk.internal.net.http.common.Utils.wrapWithExtraDetail(Unknown Source)
... 9 common frames omitted
Caused by: java.io.IOException: Connection reset by peer
at java.base/sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at java.base/sun.nio.ch.SocketDispatcher.read(Unknown Source)
at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)
at java.base/sun.nio.ch.IOUtil.read(Unknown Source)
at java.base/sun.nio.ch.IOUtil.read(Unknown Source)
at java.base/sun.nio.ch.SocketChannelImpl.read(Unknown Source)
at java.net.http/jdk.internal.net.http.SocketTube.readAvailable(Unknown Source)
at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.read(Unknown Source)
at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowTask.run(Unknown Source)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(Unknown Source)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(Unknown Source)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(Unknown Source)
at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(Unknown Source)
at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(Unknown Source)
at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowEvent.handle(Unknown Source)
at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(Unknown Source)
at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(Unknown Source)
at java.base/java.util.ArrayList.forEach(Unknown Source)
at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(Unknown Source)

Thanks!

@Krste_Tashonov Taking a look.

What version did you upgrade from? There are not many changes from 4.0.0 to 4.0.1 to cause this.

Thanks @Jay-Fauna!
We upgraded from version 3.0.1.
I think it might be worth mentioning that to that end, we started using java 11 in our solution, opposed to previously using java 8.

More context for future readers:
The application stack is AWS API Gateway with Lambda function implemented using Kotlin targeting JVM 11. We use com.faunadb:faunadb-java:4.0.1 to talk to fauna.

Solution:
With the help of @Jay-Fauna, I learned that our lambda handlers were not implemented like proposed in Known issues | Fauna Documentation. By refactoring our code, to create new fauna client object within our lambda handler function for each execution, we stopped getting these exceptions.

1 Like