question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Downloading files 500 error

See original GitHub issue

Hello,

case 1) When downloading files, only one connection can download the same file. The next connection will get a 500 error ( some exception occurred ).

case 2) If a client is downloading a file and the client connection is closed, the file remains open and the next connection gets the 500 error again.

I didn’t want to go through downloading the source code and compiling/testing again since you seem to be fixing and pulling fast and the error is obvious:

FileStream fs = new FileStream(filePath, FileMode.Open);
ctx.Response.StatusCode = 200;
ctx.Response.ContentLength = contentLength;
ctx.Response.ContentType = GetContentType(filePath);
await ctx.Response.Send(contentLength, fs);
return;

I assume all you have to do is fs.close() to close the files stream although i have not tested this. It should at least be enough for case 2.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:25 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
jchristncommented, Jan 26, 2020

Whew! I’m glad it is being caught properly now. Cheers @zaksnet thanks for all of your help.

1reaction
jchristncommented, Jan 26, 2020

Here it is!

Nuget: https://www.nuget.org/packages/Watson/3.0.7 Commit: https://github.com/jchristn/WatsonWebserver/commit/4d9993804591155b20c80039c7454125487a7f96

Here is the implementation of the RequestorDisconnected event callback (note all have return type of ‘void’ now):

        static void RequestorDisconnected(string ip, int port, string method, string url)
        {
            Console.WriteLine("RequestorDisconnected [" + ip + ":" + port + "] " + method + " " + url); 
        } 

Please let me know if your situation is caught using the RequestorDisconnected event callback once you upgrade to 3.0.7!

Read more comments on GitHub >

github_iconTop Results From Across the Web

internal server error 500 and file not downloaded although ...
i design page download file file i need to download is create but can't download although i not get any exception error. error...
Read more >
500 Internal Server Error when download file - Software Support
This means that the system cannot find or read the current file. Can you look at the path specify and check if the...
Read more >
What is “HTTP 500 Internal Server Error” and How to Fix It?
A common cause of the “Internal Server Error” is a problem within the .htaccess file. If the file is corrupted, it defines an...
Read more >
HTTP File Download 500 internal server error
When the server returns a 500 error, that means that an exception happened on the server. Unless you're using a non standards compliant ......
Read more >
Error 500 (Server errror) when downloading ...
I have requested copies of my Google Drive via Google Takeout, and received the email to say that 6 files are ready to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found