I downloaded Sample SignalR Progress Bar solution. It simulates a long running process on the server keeps updating the client using SignalR. It was working perfectly on IISExpress until I added a File.Copy(source, destination, true)
to my method in the controller (see below).
public JsonResult LongRunningProcess()
{
string directory = Server.MapPath("~/bin/") + @"\";
string source = directory + @"Templates\Template.xlsx";
string destination = directory + @"Spreadsheets\output file.xlsx";
System.IO.File.Copy(source, destination, true);
for (int i = 0; i <= 50; i++)
{
Thread.Sleep(500);
Functions.SendProgress("Process in progress...", i , 50);
}
return Json("", JsonRequestBehavior.AllowGet);
}
Now I receive a WebSocketException on server-side:
SignalR.Transports.WebSocketTransport Error: 0 : OnError(7bdc2904-8f12-4324-898f-58e4a9f4e686, System.Net.WebSockets.WebSocketException (0x800703E3): The I/O operation has been aborted because of either a thread exit or an application request
at System.Web.WebSockets.WebSocketPipe.<>c__DisplayClass9_0.<ReadFragmentAsync>b__0(Int32 hrError, Int32 cbIO, Boolean fUtf8Encoded, Boolean fFinalFragment, Boolean fClose)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.WebSockets.AspNetWebSocket.<DoWork>d__45`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.WebSockets.AspNetWebSocket.<>c__DisplayClass36_0.<<ReceiveAsyncImpl>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.SignalR.WebSockets.WebSocketMessageReader.<ReadMessageAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.SignalR.WebSockets.WebSocketHandler.<ProcessWebSocketRequestAsync>d__25.MoveNext())
and a WebSocket error on client-side:
SCRIPT12030: WebSocket Error: Network Error 12030, The connection with the server was terminated abnormally
[time] SignalR: Unclean disconnect from websocket:
[time] SignalR: Closing the Websocket.
When I checked jQuery.signalr-2.2.1.js, when onclose event raised, error code is 1000.
I also raised an issue on SignalR website. I'll be grateful if you can suggest any way to find out where/why this is happening.
More information:
I finally found out how to solve the problem. My attempt to make changes in Bin folder here:
string directory = Server.MapPath("~/bin/") + @"\";
string source = directory + @"Templates\Template.xlsx";
string destination = directory + @"Spreadsheets\output file.xlsx";
System.IO.File.Copy(source, destination, true);
was resulting in IIS recycling application domain and as a result, SignalR connection reset and throwing a WebSocketException. So, changing the first line to:
string directory = Server.MapPath("~/") + @"\";
solved my problem.
User contributions licensed under CC BY-SA 3.0