'Session handling error: Pool#acquire(Duration) has been pending for more than the configured timeout of 45000ms

I am using spring-boot-starter-graphql for simple client-server communication with websocket. Below is code snippet in client

            "ws://localhost:8080" +"/graphql";
  WebSocketClient client = new ReactorNettyWebSocketClient();
  
  WebSocketGraphQlClient graphQlClient = WebSocketGraphQlClient.builder(endPoint, client).build();
    Flux<HomeLocationResponse> locationCreateResponseMono = graphQlClient.documentName("location-document") 
            .variable("msisdn", getLocationRequest.getMsisdn()) 
            .variable("transactionid", getLocationRequest.getTransactionId()) 
            .retrieveSubscription("getLocation")
            .toEntity(HomeLocationResponse.class)

On top of this I have created the REST endpoint which invokes this code. This works well for first 500 request after I start this service but after 500 request It breaks and I am seeing multiple errors with below stack trace

2022-04-26 18:39:34.868 ERROR 102456 --- [ parallel-2] o.s.g.client.WebSocketGraphQlTransport : Session handling error: Pool#acquire(Duration) has been pending for more than the configured timeout of 45000ms
2022-04-26 18:39:34.869 ERROR 102456 --- [ parallel-2] reactor.core.publisher.Operators : Operator called default onErrorDropped

reactor.netty.internal.shaded.reactor.pool.PoolAcquireTimeoutException: Pool#acquire(Duration) has been pending for more than the configured timeout of 45000ms
at reactor.netty.internal.shaded.reactor.pool.AbstractPool$Borrower.run(AbstractPool.java:415) ~[reactor-netty-core-1.0.17.jar:1.0.17]
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68) ~[reactor-core-3.4.16.jar:3.4.16]
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28) ~[reactor-core-3.4.16.jar:3.4.16]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:831) ~[na:na]

I am new to websocket and not sure why the websocket connection is not getting closed.

My scenario for Microsevices involved is as below.

1. GraphQLClient Microservice 2. GraphQl Server Microservice

GraphQLClient Microservice again exposes the REST endpoint as wrapper.

So following flow will be executed Browser -> GraphQLClient <-> GraphQlServer



Solution 1:[1]

So after connecting on the https://github.com/spring-projects/spring-graphql/issues/369

and adding graphQlClient.stop().subscribe(); can resolve the problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Viral Kondhia