jsreport / jsreport-dotnet-aspnetcore

Asp.net core and MVC support for jsreport c# sdk
MIT License
11 stars 8 forks source link

jsreport doesn't free localhost address binding on server shutdown #9

Closed Carnid closed 5 years ago

Carnid commented 5 years ago

Hello, whenever I try to restart my dotnet core mvc app with jsreport, it complains that the address is already in use. I need to go into my task manager to force kill jsreport.exe to free the port. System.IO.IOException: Failed to bind to address http://[::]:5820: address already in use. ---> Microsoft.AspNetCore.Connections.AddressInUseException: Address already in use ---> System.Net.Sockets.SocketException: Address already in use I am running on Mac OSX and using the configurations from the example.

            services.AddJsReport(new LocalReporting()
                .UseBinary(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
                    ? JsReportBinary.GetBinary()
                    : jsreport.Binary.OSX.JsReportBinary.GetBinary())
                .AsUtility()
                .Create());

It works well the first time, my reports generate and all. However, it's quite annoying to have to kill the jsreport.exe process every time. Is there a configuration I am missing?

Thank you

pofider commented 5 years ago

Hi,

you can use new LocalReporting().KillRunningJsReportProcesses().... to do cleanup.

We automatically kill jsreport process on domain unload, unfortunately, it is sometimes not called by .net. So far don't know how to improve it, so closing this.