无法从服务器读取任何响应,底层连接可能会意外丢失 (vert.x)

huangapple go评论71阅读模式
英文:

Fail to read any response from the server, the underlying connection might get lost unexpectedly (vert.x)

问题

我尝试向数据库插入数据。在插入数据时,我遇到了来自vert.x的问题。

vertx 4.4.0错误 => io/vertx/sqlclient/ClosedConnectionException

vertx 4.3.8错误 => 无法从服务器读取任何响应,底层连接可能会意外丢失。

这个错误每次在插入数据时都会发生。但是从数据库读取数据时正常运行。

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);

}

我尝试了很多方法

  1. 我将超时时间从3秒增加到5分钟,但仍然遇到相同的错误。
  2. 我尝试为数据库创建一个新用户,但仍然不起作用。
  3. 我尝试更改mssql-client的版本。
  4. 当我在较低的环境中运行相同的代码时,它正常工作。它只在生产环境中出现错误。所以我不确定是需要在代码中进行更改还是需要在数据库端进行一些更改。

现在我已经没有其他选项来解决这个问题。你能帮忙吗?

英文:

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
> 1. I added timeout from 3 seconds to 5 minutes but still getting the same error.
> 2. I tried creating a new user for DB, still it doesn't work.
> 3. I tried changing the version of the mssql-client.
> 4. 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

得分: 0

我找到了两个解决方案。

  • 我们可以将 vert.x 中的 mssql-client 版本降级到 4.3.1,该版本与当前的 RDS 版本 15.00.4073.23.v1 兼容。
  • 或者,我们可以保持 vert.x 中的 mssql-client 版本为 4.3.8,并升级生产数据库的 RDS 版本到 15.00.4236.7.v1。

兼容性表格

Ms-sql Client 4.3.8 RDS(SQL Server) 15.00.4236.7.v1
4.3.1 15.00.4073.23.v1

英文:

I found out two solutions.

  • We can reduce the version of mssql-client in vert.x to 4.3.1, which is compatible with the current RDS version of 15.00.4073.23.v1.
  • Alternatively, we can keep the mssql-client version of vert.x at 4.3.8 and upgrade the production database's RDS version to 15.00.4236.7.v1.

Compatibility Chart

Ms-sql Client 4.3.8 RDS(Sql server) 15.00.4236.7.v1
              4.3.1                 15.00.4073.23.v1

huangapple
  • 本文由 发表于 2023年4月4日 17:13:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75927558.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定