We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
roman prog 89 level_
4 years agoExplorer | Level 3
How to continue if the connection is interrupted.
Hi everyone. File unload question. How to continue if the connection is interrupted. An example of my code.
using (var stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileS...
- 4 years ago
The "Access to a closed stream is not possible" error message doesn't appear to be coming from the Dropbox API itself, so I can't offer too much help with that in particular. That said, it's likely referring to that "memStream" object. It looks like that's closed, since it was used in the first attempt, so you'd need to make a new one for the new attempt.
Greg-DB
Dropbox Community Moderator
4 years agoCan you elaborate on what you mean when you say "it doesn't work"? What unexpected error, output, or behavior are you getting? I recommend stepping through with the debugger first to see what is being executed and when to understand what is happening.
roman prog 89 level_
4 years agoExplorer | Level 3
I'll tell you more.
I'm testing the problem with unloading, in the debugger, manually turning off the Internet.
When an error occurs in UploadSessionAppendV2Async, the message is: "An error occurred while copying content to the stream. - - - System.IO.IOException: Cannot write data to transport connection: The remote host forcibly terminated the existing connection. ---> System .Net.Sockets.SocketException: The remote host forcibly terminated an existing connection"
Next, I intercept the error, try to re-upload through
UploadSessionAppendV2Async but getting error: "Access to a closed stream is not possible."
else
{
try
{
await dbx2.Files.UploadSessionAppendV2Async(cursor, close:false, body: memStream); // if there is an upload error - An error occurred while copying content to the stream.
Log(DateTime.Now + " - TRYING - " + i + " - FRAGMENT PART - " + idx);
}
catch (Exception yt)
{
Log(yt.Message + " - - - " + yt.InnerException + " - - - " + yt.TargetSite);
System.Threading.Thread.Sleep(pause);
try
{
await dbx2.Files.UploadSessionAppendV2Async(cursor, close: false, body: memStream); //there is no reloading at this point. - Access to a closed stream is not possible.
}
catch (Exception er)
{
Log("TRAYING ERROR - " + " - " + er.Message);
}
}
}
I don’t understand why the stream is closing, how can I connect to it again?
- Greg-DB4 years ago
Dropbox Community Moderator
The "Access to a closed stream is not possible" error message doesn't appear to be coming from the Dropbox API itself, so I can't offer too much help with that in particular. That said, it's likely referring to that "memStream" object. It looks like that's closed, since it was used in the first attempt, so you'd need to make a new one for the new attempt.
- roman prog 89 level_4 years agoExplorer | Level 3
Thanks a lot. You're right.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!