On 3/28/2017 8:13 AM, Mikhail Ibraheem wrote: > I have a project with solr and spring. I am have only one instance of > CloudSolrClient at the context (singleton). > > This is because I believe that it should be only one instance to load balance > between the nodes.
Yes, the intent is to be fully threadsafe. You should know that HttpClient, the class which the SolrClient implementations use under the hood, has a default limitation of only allowing two simultaneous connections to a given route, which I believe means a host/port combination. Increasing this is possible, but it must be done by creating a custom HttpClient object. Here's some code that I use to build such a client, then use that client to create an HttpSolrClient. The same thing can be done with CloudSolrClient: RequestConfig rc = RequestConfig.custom().setConnectTimeout(15000) .setSocketTimeout(Const.SOCKET_TIMEOUT).build(); httpClient = HttpClients.custom().setDefaultRequestConfig(rc) .setMaxConnPerRoute(300).setMaxConnTotal(5000).disableAutomaticRetries() .build(); client = new HttpSolrClient(serverBaseUrl, httpClient); > I have big issue which doesn't occur all the times, it is intermittent: > > java.lang.ClassCastException: java.lang.String cannot be cast to > org.apache.solr.common.SolrDocumentList That is odd. What is the exact version of SolrJ that you are using, and the version of the SolrCloud cluster that it is talking to? Can you share your SolrJ code? Thanks, Shawn