WatsonWebserver: Downloading files 500 error
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.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 25
Whew! I’m glad it is being caught properly now. Cheers @zaksnet thanks for all of your help.
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):Please let me know if your situation is caught using the
RequestorDisconnected
event callback once you upgrade to 3.0.7!So strange. When I cancel a download in Chrome, the exception is being caught by the new
RequestorDisconnected
event, which is catching onHttpListenerException
.I’m looking for a reference on the possible
HResult
values forIOException
so I can accurately filter on socket-related exceptions and handle them the same way asHttpListenerException
. Stay tuned.Thanks @zaksnet I will do that (both)! Reopening so I can track on my end.