I am creating a spring boot application and trying to connect Mongo DB atlas and its giving me below exception :
com.mongodb.MongoSocketReadException: Prematurely reached end of stream
at com.mongodb.internal.connection.SocketStream.read(SocketStream.java:112) ~[mongodb-driver-core-4.0.4.jar:na]
Connection string in application.properties:
spring.data.mongodb.uri=mongodb+srv://<user>:<pass>#abc.mongodb.net/test?ssl=false&connectTimeoutMS=1000&socketTimeoutMS=1000
Related
I am using spring data Couchbase to connect to the Couchbase database from my spring boot application . And I am directly connecting to the Bucket using bucket name and password. But when there is any database maintenance(linux patching/db restart) then connection is getting break and it's not automatically restored when database maintenance is over. And I get "ConcurrentTimeout Exception". and I have to restart the application to connect to the database.
Is there any setting/configuration that I can do to restore the connection automatically?
version:
spring-data-couchbase :2.2.20.release and Couchbase server: 6.6
The java SDK will only try to connect for the duration specified by the kv connect timeout. To try for up to one hour, modified the couchbase environment by overriding the configureEnvironment() method in AbstractCouchbaseConfiguration.
#Override
protected void configureEnvironment(ClusterEnvironment.Builder builder) {
builder.timeoutConfig().connectTimeout(Duration.ofSeconds(3600));
}
In the 2.x SDK, I believe this would be
DefaultCouchbaseEnvironment.builder().socketConnectTimeout()
https://docs.couchbase.com/sdk-api/couchbase-core-io-1.7.12/com/couchbase/client/core/env/DefaultCoreEnvironment.Builder.html
I have spring boot application which starts H2 db with below URL
jdbc:h2:~/data/test;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;TRACE_LEVEL_SYSTEM_OUT=3;AUTO_SERVER_PORT=52002;AUTO_RECONNECT=TRUE
After this i run a test suit which also connects to same H2 instance but at this time i get. At this application is still running and I can access the H2 console
Connection is broken: "java.io.EOFException: 192.168.1.178:52002" [90067-200]
I have Spring boot mongo db app, when i start running this application if mongo host is alive, am able to see the my app is up and running successfully,
if my mongo host is down when i start my application my app failed to start.
is there any way even thought if mongo host is down my application should be up and running.
could someone please help me on this?
am using spring boot mongo properties in my application
spring.data.mongodb.repositories.enabled=true
spring.data.mongodb.port=27017
spring.data.mongodb.database=db
spring.data.mongodb.uri=mongodb://mongo-node-1.ballu/db
have same problem with spring boot kafka also.
Sorry for the previous comment. It was for excluding auto config beans, anyway
Is there any way even though if mongo host is down my application
should be up and running.
Yes,
spring.datasource.continue-on-error=true #Whether to stop if an error occurs while initializing the database.
as per spring doc
By default, Spring Boot enables the fail-fast feature of the Spring
JDBC initializer. This means that, if the scripts cause exceptions,
the application fails to start. You can tune that behavior by setting
spring.datasource.continue-on-error.
and as of spring kafka try this(i'm not sure if this meets your requirement)
spring.kafka.admin.fail-fast=true # Whether to fail fast if the broker is not available on startup.
I am using Reactive Spring Boot (Flux) for infinite streams and #Tailable in a Reactive Mongo Repository to enable server side events. For each request to the Flux controller, it is creating a brand new MongoDB connection, although I am using the reactive Mongo client to create the connection. Because of this after 100 connections the application is throwing a MongoDB connection timeout exception. Below is my code.
REST Controller
Reactive Mongo Repository :
Please advise, if anyone knows how to fix this!
We are using Spring boot and Spring Data gemfire , We have configured a ClientCache (PROXY one) and trying to connect to our local region , When i do a region.put it gives the below error
Caused by: org.apache.geode.cache.client.NoAvailableServersException
at org.apache.geode.cache.client.internal.pooling.ConnectionManagerImpl.borrowConnection(ConnectionManagerImpl.java:234)
Running it as a pure java application , Im able to get/put from the cache.