没有在spring集成中定义SSL握手超时的选项

时间:2016-12-13 11:10:26

标签: spring timeout spring-integration handshaking

我在我的一个应用程序中使用spring集成与银行进行通信。在负载很重的情况下,我们收到错误“org.springframework.messaging.MessagingException:SSL握手耗时太长”。银行要求我们将超时设置为90秒。 在查看TcpNioSSLConnection类的代码时,我发现30秒是硬编码的。

private HandshakeStatus waitForHandshakeData(SSLEngineResult result,
            HandshakeStatus status) thr`enter code here`ows IOException {
            try {
                if (logger.isTraceEnabled()) {
                    logger.trace("Writer waiting for handshake");
                }
            if (!TcpNioSSLConnection.this.semaphore.tryAcquire(30, TimeUnit.SECONDS)) {
                throw new MessagingException("SSL Handshaking taking too long");
            }
            if (logger.isTraceEnabled()) {
                logger.trace("Writer resuming handshake");
            }
            status = runTasksIfNeeded(result);
        }
        catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new MessagingException("Interrupted during SSL Handshaking");
        }
        return status;
    }

如果有任何方法可以增加ssl握手超时,请建议我

下面是我的弹簧集成连接工厂配置

 <int-ip:tcp-connection-factory id="client"
            type="client" port="${cbs.third.party.port}"  host="${cbs.third.party.host}"
            single-use="true" using-nio="true" deserializer="javaDeserializer"
            serializer="javaSerializer" ssl-context-support="sslContextSupport" task-executor="myTaskExecutor"/>

谢谢, 罗希特夏尔

1 个答案:

答案 0 :(得分:0)

目前无法配置该超时;我打开了JIRA Issue

您可以尝试将use-nio设为false;除非您长时间打开很多插座,否则通常不需要它。