From ac0ae563394e9b9a201051c6cfe1a306531d3a63 Mon Sep 17 00:00:00 2001 From: Maxim Valyanskiy Date: Sun, 3 Nov 2024 14:46:04 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=BD=D1=8F=D0=BB=20socket?= =?UTF-8?q?=20timeout=20=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/linux/search/ElasticsearchConfiguration.scala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/scala/ru/org/linux/search/ElasticsearchConfiguration.scala b/src/main/scala/ru/org/linux/search/ElasticsearchConfiguration.scala index 5b74d985a2..d995f23aba 100644 --- a/src/main/scala/ru/org/linux/search/ElasticsearchConfiguration.scala +++ b/src/main/scala/ru/org/linux/search/ElasticsearchConfiguration.scala @@ -1,5 +1,5 @@ /* - * Copyright 1998-2022 Linux.org.ru + * Copyright 1998-2024 Linux.org.ru * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,6 +17,8 @@ package ru.org.linux.search import com.sksamuel.elastic4s.http.JavaClient import com.sksamuel.elastic4s.{ElasticClient, ElasticProperties} +import org.apache.http.client.config.RequestConfig +import org.elasticsearch.client.RestClientBuilder.RequestConfigCallback import org.springframework.context.annotation.{Bean, Configuration} import ru.org.linux.spring.SiteConfig @@ -24,6 +26,10 @@ import ru.org.linux.spring.SiteConfig class ElasticsearchConfiguration(config: SiteConfig) { @Bean(destroyMethod = "close") def client: ElasticClient = { - ElasticClient(JavaClient(ElasticProperties(config.getElasticsearch))) + ElasticClient(JavaClient(ElasticProperties(config.getElasticsearch), new RequestConfigCallback() { + override def customizeRequestConfig(requestConfigBuilder: RequestConfig.Builder): RequestConfig.Builder = { + requestConfigBuilder.setSocketTimeout(120000) + } + })) } }