1

I am getting this error while migrating content from one alfresco repository to other.

And I am getting this error on live production server logs.

And also Server is getting down while migration is running.

Can anyone please help me to resolve this issue or any suggestion is there to avoid this issue.

Any help or comments will be appreciated. Thanks in Advance.

I have written below code snippet

ContentStream contentStream = new ContentStreamImpl("content." + FilenameUtils.getExtension(fileName),
            BigInteger.valueOf(fileName.length()), new MimetypesFileTypeMap().getContentType(newfile), doc.getContentStream().getStream());

I have 2 repositorys,Using above code I am reading content stream from source and creating new file in target repository and adding the content stream. But I didn't found any way to to close the content stream.

Please find below error log for more details.

java.net.SocketException: Too many open files at java.net.PlainSocketImpl.socketAccept(Native Method)

Deepak Talape
  • 997
  • 1
  • 9
  • 35
  • 2
    Possible duplicate of [Java Too Many Open Files](https://stackoverflow.com/questions/4289447/java-too-many-open-files) – Akah Sep 27 '17 at 15:01
  • Actually I am using CMIS API, and there I am not using any writter object – Deepak Talape Sep 27 '17 at 15:30
  • Sorry, but your question wasn't clear enaough for me. I wasn't sure that you knew what a "too many open file issue is". Could you explain what you mean by migration and what you exactly do ? Could you monitor your system open files, to see if you have a leak, or just that your migration mecanism is using too many system ressources ? – Akah Sep 28 '17 at 06:46
  • You've tagged your question with "dotcmis", but your code snippet is Java, not .Net. I guess, the tag should be "opencmis". – Florian Müller Sep 28 '17 at 07:29
  • You are providing the wrong length in your code snippet. It should be the length of the stream, not the length of the file name. – Florian Müller Sep 28 '17 at 07:42
  • Sorry @FlorianMüller mystically it out dotcmis tag, now I have edited. Thanks – Deepak Talape Sep 28 '17 at 15:53
  • Can you share your CMIS query? Have you tried limiting it to work on smaller sets of data, in multiple passes? – rotarydial Oct 01 '17 at 04:22

1 Answers1

1

If you are using the DotCMIS method GetContentStream on the client side, make sure you always close the stream - even if you are not reading it. Otherwise, the socket to the server stays open. Depending on your application the client and/or the server can run out of sockets.

Closing the stream works like this:

IContentStream contentStream = document.GetContentStream();
Stream stream = contentStream.Stream;

... do something with the stream ...

stream.Close();
Florian Müller
  • 3,215
  • 1
  • 14
  • 11
  • Thanks @Florian Muller This is what I am doing. Can you please help me with closing the stream. Because I tried at my level but I ditn't found any way to close the stream. – Deepak Talape Sep 28 '17 at 06:39
  • @DeepakTalape please share your code in your question. – Akah Sep 28 '17 at 06:49