jsreport / jsreport-dotnet

jsreport .NET sdk home repository
https://jsreport.net
MIT License
63 stars 9 forks source link

Error when jsreport with ASP.net core #38

Closed SwethaYamsani closed 5 years ago

SwethaYamsani commented 5 years ago

I get the below error. I tried to the jsreport.exe from the folder it is installed with the below command jsreport start --httpPort=5488. shows the same error in cmd too.

An unhandled exception occurred while processing the request. JsReportBinaryException: Error rendering report: A critical error occurred while trying to execute the render command: An error occurred while trying to start daemonized process: An error has occurred when trying to initialize jsreport, seems like there is already a server running in port: 5488 (2). listen EADDRINUSE :::5488 (1). caused by error (2) -> meta = {"code":"EADDRINUSE"}, stack = Error: at instance.init.then.catch ([eval]:66283:29) at tryCatcher (jsreportRuntime.js:158306:23) at Promise._settlePromiseFromHandler (jsreportRuntime.js:157998:31) at Promise._settlePromise (jsreportRuntime.js:158055:18) at Promise._settlePromise0 (jsreportRuntime.js:158100:10) at Promise._settlePromises (jsreportRuntime.js:158176:18) at _drainQueueStep (jsreportRuntime.js:39442:12) at _drainQueue (jsreportRuntime.js:39435:9) at Async._drainQueues (jsreportRuntime.js:39451:5) at Immediate.Async.drainQueues (jsreportRuntime.js:39321:14) at runCallback (timers.js:794:20) at tryOnImmediate (timers.js:752:5) at processImmediate [as _immediateCallback] (timers.js:729:5)caused by error (1) -> meta = {"code":"EADDRINUSE","errno":"EADDRINUSE","syscall":"listen","address":"::","port":5488}, stack = Error: at Object._errnoException (util.js:1022:11) at _exceptionWithHostPort (util.js:1044:20) at Server.setupListenHandle [as _listen2] (net.js:1367:14) at listenInCluster (net.js:1408:12) at Server.listen (net.js:1492:7) at Promise (jsreportRuntime.js:182856:12) at Promise._execute (jsreportRuntime.js:40237:9) at Promise._resolveFromExecutor (jsreportRuntime.js:157969:18) at new Promise (jsreportRuntime.js:157565:10) at startAsync (jsreportRuntime.js:182850:10) at steps.push (jsreportRuntime.js:182884:14) at Object.start (jsreportRuntime.js:182958:13) at Object.reporter.initializeListeners.add (jsreportRuntime.js:183141:30) at (1). caused by error (1) -> meta = {"code":"EADDRINUSE"}, stack = Error: at exports.NsSocket.socket.dataOnce ([eval]:66671:25) at exports.NsSocket.listener ([eval]:13402:10) at exports.NsSocket.EventEmitter.emit ([eval]:13490:22) at exports.NsSocket._onData ([eval]:94250:8) at Lazy. ([eval]:74361:13) at Lazy. ([eval]:74343:19) at emitTwo (events.js:126:13) at Lazy.emit (events.js:214:7) at Lazy. ([eval]:74344:22) at emitOne (events.js:116:13) at Lazy.emit (events.js:211:7) at yieldTo ([eval]:74451:18) at Function. ([eval]:74489:27) at Lazy. ([eval]:74457:21) at emitOne (events.js:116:13) at Lazy.emit (events.js:211:7)

pofider commented 5 years ago

EADDRINUSE :::5488... This means there is something occupying the port 5488 which jsreport wants to use. In most cases, it is a jsreport orphan. Try to check the taskmgr and kill node processes. You can also use jsreport.Local shortcut to kill all running jsreport orphans.

https://jsreport.net/learn/dotnet-local

var rs = new LocalReporting()
     .UseBinary(JsReportBinary.GetBinary())
     .KillRunningJsReportProcesses()
    ....
mlakhara commented 3 years ago

@pofider First of all thanks for this amazing library. Kudos on the work done.

I am using the method KillRunningJsReportProcesses in Application Startup, still when I restart the app, it gives me the same error. Here is my code

services.AddJsReport(
            new LocalReporting()
            .Configure(cfg => { cfg.HttpPort = 5483; return cfg; })
           .UseBinary(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? jsreport.Binary.JsReportBinary.GetBinary() : jsreport.Binary.Linux.JsReportBinary.GetBinary())
           .KillRunningJsReportProcesses()
           .AsUtility()
           .Create()
          );
pofider commented 3 years ago

@mlakhara Thanks. Maybe the app doesn't have permission to kill the node process or it was started from a different directory. Try to open the task manager and kill all node.exe processes manually.