ContentStreamUpdateRequest error de escritura del socket al enviar cadenas grandes

I get the following exception when sending data to solr using the ContentStreamUpdateRequest of SolrJ

Exception in thread "main" org.apache.solr.client.solrj.SolrServerException: Software caused connection abort: socket write error
    at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(
    at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(
    at com.atosworldline.documentarchiver.core.solr.SolrIndexer.addDocument(
    at com.atosworldline.documentarchiver.core.solr.SolrIndexerTest.main(
Caused by: Software caused connection abort: socket write error
    at Method)
    at org.apache.commons.httpclient.HttpConnection.write(
    at org.apache.commons.httpclient.HttpConnection.write(
    at org.apache.commons.httpclient.HttpConnection.print(
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.print(
    at org.apache.commons.httpclient.HttpMethodBase.writeRequestLine(
    at org.apache.commons.httpclient.HttpMethodBase.writeRequest(
    at org.apache.commons.httpclient.HttpMethodBase.execute(
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(
    at org.apache.commons.httpclient.HttpClient.executeMethod(
    at org.apache.commons.httpclient.HttpClient.executeMethod(
    at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(
    ... 3 more

The reason for that exception is, that I'm sending the binary data of the document to solr. If I remove this, the application runs successfull. I'm using the following code to send the request

SolrServer solrServer = new CommonsHttpSolrServer(url);
ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(EXTRACT);

//request.setParam("", documentName);
request.setAction(ACTION.COMMIT, true, true);
byte[] byteContent = FileUtils.readFileToByteArray(document);
String base64encodedFile = Base64.byteArrayToBase64(byteContent, 0, byteContent.length);
request.setParam(SolrDBSchema.DOCUMENT.toString(), base64encodedFile);
request.setParam("literal." + SolrDBSchema.OWNER.toString(), owner);
request.setParam("literal." + SolrDBSchema.VALID.toString(), Boolean.toString(valid));
request.setParam("literal." + SolrDBSchema.DATE.toString(), validFor.toString());
request.setParam("literal." + SolrDBSchema.DOCUMENT_TYPE.toString(), documentType);

I think the String base64encodedFile is to long for a HTTP request, but I don't know a solution for that problem. As far as I know Solr is not able to store the document by configuration.

preguntado el 08 de noviembre de 11 a las 09:11

1 Respuestas

Since you are using SolrJ, consider setting the RequestWriter to use the BinaryRequestWriter, like this:

   solrServer.setRequestWriter(new BinaryRequestWriter());

This will allow you to write your data to Solr in the binary format and may bypass the issue you are experiencing sending the large data stream as XML.

Note that you will need to ensure you have the BinaryUpdateRequestHandler enabled in your solrconfig.xml settings.

  <requestHandler name="/update/javabin" class="solr.BinaryUpdateRequestHandler" /> 

respondido 08 nov., 11:17

I still get the same exception. I dived into the code. The problem is, that it's hardcoded in the CommonsHttpSolrServer to send the parameters as a HTTP GET request. If I'd able to send them as POST request it wouldn't be a problem. So I should request that as a new feature. - itsme

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.