com.datastax.oss.driver.api.core.drivertimeoutexception:查询'select*from system.local'在pt0.5s后超时

4ktjp1zp  于 2021-06-10  发布在  Cassandra
关注(0)|答案(0)|浏览(491)

当我试图运行我的java应用程序,它试图连接到cassandra时,我得到以下异常:

com.datastax.oss.driver.api.core.DriverTimeoutException: query 'SELECT * FROM system.local' timed out after PT0.5S

    DriverConfigLoader configBuilder = DriverConfigLoader.programmaticBuilder()
                .withClass(DefaultDriverOption.AUTH_PROVIDER_CLASS, PlainTextAuthProvider.class)
                .withString(DefaultDriverOption.AUTH_PROVIDER_USER_NAME, user)
                .withString(DefaultDriverOption.AUTH_PROVIDER_PASSWORD, pass)
                .withBoolean(DefaultDriverOption.CONNECTION_WARN_INIT_ERROR, false)
                .withInt(DefaultDriverOption.CONNECTION_MAX_REQUESTS, 32768)
                .withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofSeconds(30))
                .withDuration(DefaultDriverOption.CONNECTION_INIT_QUERY_TIMEOUT, Duration.ofSeconds(10)).build();

        try {
            cqlSession = CqlSession.builder().addContactPoints(hostsList).withKeyspace(keyspace)
                    .withLocalDatacenter(dataCenter).withConfigLoader(configBuilder).build();
        } catch (Exception e) {
            logger.error("CassandraConfig >> Unable to connect to database {}", e);
        }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题