0

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

Brian Clozel
  • 56,583
  • 15
  • 167
  • 176
Viral Kondhia
  • 51
  • 1
  • 10
  • 1
    The exception that you see is exactly because the pool has max connections 500 and you do not close them. So your problem here is not this exception but why the connections are not closed. – Violeta Georgieva Apr 27 '22 at 08:46
  • @VioletaGeorgieva Thanks -- I actually mentioned that in the question **I am new to websocket and not sure why the websocket connection is not getting closed.** – Viral Kondhia Apr 27 '22 at 08:49

1 Answers1

0

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

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

Viral Kondhia
  • 51
  • 1
  • 10
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 12 '22 at 09:10