Learn how to make the most out of the Dropbox Community here 💙!
Forum Discussion
roman prog 89 level_
3 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...
- 3 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.
roman prog 89 level_
3 years agoExplorer | Level 3
yes, I am doing error trapping.
But when I try to re-upload it doesn't work. although the connection has already been restored. I'm trying it on the bench.
It is noticeable that he does not even try to unload.
else
{
try
{
await dbx2.Files.UploadSessionAppendV2Async(cursor, close:false, body: memStream); // if there is an upload error
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.
}
catch (Exception er)
{
Log("TRAYING ERROR - " + " - " + er.Message);
}
}
}
Greg-DB
Dropbox Staff
3 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_3 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-DB3 years ago
Dropbox Staff
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_3 years agoExplorer | Level 3
Thanks a lot. You're right.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,973 PostsLatest Activity: 6 hours ago
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 or Facebook.
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!