I am trying to insert data into a db. While inserting the data I am getting an issue from vert.x saying
vertx 4.4.0 error => io/vertx/sqlclient/ClosedConnectionException
vertx 4.3.8 error => Fail to read any response from the server, the underlying connection might get lost unexpectedly.
This error is occurring every-time on INSERT in DB. But working on READ from DB
public static MSSQLPool createMssqlDbPool(Vertx vertx, DbConfig dbConfig) {
MSSQLConnectOptions connectOptions = new MSSQLConnectOptions()
.setHost(System.getenv().getOrDefault("DB_HOST", dbConfig.getHost()))
.setPort(Integer.parseInt(System.getenv().getOrDefault("DB_PORT", dbConfig.getPort())))
.setDatabase(System.getenv().getOrDefault("DB_NAME", dbConfig.getDatabase()))
.setUser(System.getenv().getOrDefault("DB_USER", dbConfig.getUser()))
.setPassword(System.getenv().getOrDefault("DB_PASSWORD", dbConfig.getPassword()));
// Pool options
PoolOptions poolOptions = new PoolOptions()
.setMaxSize(5);
LOG.info("DB connection : {}", connectOptions.toJson());
return MSSQLPool.pool(vertx, connectOptions, poolOptions);
}
I have tried a lot of things
- I added timeout from 3 seconds to 5 minutes but still getting the same error.
- I tried creating a new user for DB, still it doesn't work.
- I tried changing the version of the mssql-client.
- When i run the same code in lower environments its workinf fine. It gives error only on production. So i am not sure if we need to do changes in code or there should be some change in the DB side.
Now I am put of options as to why it is not working. Can you please help.
1条答案
按热度按时间ldioqlga1#
The error message you are receiving is indicating that the connection to the database is closed when you are trying to insert data. There could be various reasons for this error, such as:
To investigate the issue further, you could try adding some logging statements to your code to see where the error is occurring. You could also check the database server logs to see if there are any errors or warnings that could be related to this issue.
It might also be helpful to check the documentation for the MSSQLPool class to see if there are any additional configuration options or settings that you need to configure to avoid this issue.