Java Developer
Java Developer

Reputation: 21

Getting com.mongodb.MongoTimeoutException in Gravitee access management api

We are trying to upgrade Gravitee from 1.2 to 3.15 using Docker. Mongodb version is 4.2. While trying to use access management api getting 504 response. In Gravitee access management API logs getting the below error :

io.reactivex.exceptions.OnErrorNotImplementedException: The exception was not handled due to missing onError handler in the subscribe() method call. Further reading: https://github.com/ReactiveX/RxJava/wiki/Error-Handling | com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]
        at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
        at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
        at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:77)
        at io.reactivex.internal.operators.observable.ObservableFromPublisher$PublisherSubscriber.onError(ObservableFromPublisher.java:51)
        at reactor.core.publisher.StrictSubscriber.onError(StrictSubscriber.java:106)
        at reactor.core.publisher.FluxConcatArray$ConcatArraySubscriber.onError(FluxConcatArray.java:207)
        at reactor.core.publisher.MonoIgnoreElements$IgnoreElementsSubscriber.onError(MonoIgnoreElements.java:84)
        at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondError(MonoFlatMap.java:192)
        at reactor.core.publisher.MonoFlatMap$FlatMapInner.onError(MonoFlatMap.java:259)
        at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onError(MonoPeekTerminal.java:258)
        at reactor.core.publisher.MonoCreate$DefaultMonoSink.error(MonoCreate.java:194)
        at com.mongodb.reactivestreams.client.internal.MongoOperationPublisher.lambda$sinkToCallback$30(MongoOperationPublisher.java:545)
        at com.mongodb.reactivestreams.client.internal.OperationExecutorImpl.lambda$execute$8(OperationExecutorImpl.java:107)
        at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:48)
        at com.mongodb.internal.operation.CreateIndexesOperation$2.call(CreateIndexesOperation.java:214)
        at com.mongodb.internal.operation.OperationHelper$AsyncCallableWithConnectionCallback.onResult(OperationHelper.java:689)
        at com.mongodb.internal.operation.OperationHelper$AsyncCallableWithConnectionCallback.onResult(OperationHelper.java:681)
        at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:48)
        at com.mongodb.internal.binding.AsyncClusterBinding$1.onResult(AsyncClusterBinding.java:117)
        at com.mongodb.internal.binding.AsyncClusterBinding$1.onResult(AsyncClusterBinding.java:113)
        at com.mongodb.internal.connection.BaseCluster$ServerSelectionRequest.onResult(BaseCluster.java:430)
        at com.mongodb.internal.connection.BaseCluster.handleServerSelectionRequest(BaseCluster.java:306)
        at com.mongodb.internal.connection.BaseCluster.access$800(BaseCluster.java:62)
        at com.mongodb.internal.connection.BaseCluster$WaitQueueHandler.run(BaseCluster.java:476)
        at java.base/java.lang.Thread.run(Unknown Source)
Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused}}]
        at com.mongodb.internal.connection.BaseCluster.createTimeoutException(BaseCluster.java:405)
        ... 4 more

Upvotes: 2

Views: 386

Answers (1)

Leleu Eric
Leleu Eric

Reputation: 31

How do you deploy AM and Mongo, using docker-compose or by starting containers one by one ?

According to the error, the AM service is trying to connect the MongoDB on Localhost:27017. If you are running AM and Mongo into containers, you probably have to adapt the gravitee.yaml file of AM to connect to MongoDB with the right parameters.

In addition, as you are talking of upgrade, remenber to follow the migration guides : https://docs.gravitee.io/am/current/am_installguide_migration.html

Upvotes: 1

Related Questions