Skip to main content
Question

Couldn't finish closing the connection to the Box API due to a network error or because the stream w

  • May 22, 2025
  • 2 replies
  • 73 views

Forum|alt.badge.img

I am using the box java sdk 2.8.2 to move some folders around as a part of automation.

A call to public BoxFolder.Info moveFolderToUser​(String sourceUserID) throws the following exception . The move happens succesfully but the BoxFolder.Info object is null. Any thoughts?


com.box.sdk.BoxAPIException: Couldn't finish closing the connection to the Box API due to a network error or because the stream was already closed.
at com.box.sdk.BoxAPIResponse.disconnect(BoxAPIResponse.java:192)
at com.box.sdk.BoxUser.moveFolderToUser(BoxUser.java:445)
at com..box.BoxTermProcessAutomation.moveTerminatedUserFolders(BoxTermProcessAutomation.java:430)
at com..box.BoxTermProcessAutomation.main(BoxTermProcessAutomation.java:59)
Caused by: java.io.IOException: stream is closed
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.ensureOpen(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
at com.box.sdk.BoxAPIResponse.disconnect(BoxAPIResponse.java:182)
... 3 more

 

 

2 replies

Forum|alt.badge.img

 This GitHub issue seems similar to the issue you are seeing. Is there something in your program that is setting a timeout on the execution of the code calling the Box API? 


Forum|alt.badge.img

No there is nothing in my code like that.

 

The public BoxFolder.Info moveFolderToUser(String sourceUserID)  method in BoxUser class calls the disconnect() method in BoxJSONResponse which is throwing this exception