ElectronNET / Electron.NET

:electron: Build cross platform desktop apps with ASP.NET Core (Razor Pages, MVC, Blazor).

Home Page:https://gitter.im/ElectronNET/community

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to load URL: http://localhost:8001/ with error: ERR_CONNECTION_RESET

nazar322 opened this issue · comments

  • Version: 23.6.1
  • .NET: 6
  • Node: v18.15.0

After updating Electron.NET to 23.6.1 I can't no longer start my app, I have this error all the time
Got disconnect! Reason: transport close (node:16976) electron: Failed to load URL: http://localhost:8001/ with error: ERR_CONNECTION_RESET (Use electron --trace-warnings ... to show where the warning was created)
how can I add --trace-warnings to electron?
This is how I launch the app electronize start /args "--remote-debugging-port=9222" /dotnet-configuration "Release_Windows"
I have tried running it like this electronize start /args "--remote-debugging-port=9222 --trace-warnings" /dotnet-configuration "Release_Windows" but it did not change anything in the output

Not a bug looks like but I have asked at Gitter and no one replied.

In TCPView I see that port 8001 has been created and connected by electron.exe but a few seconds later the port gets closed and Got disconnected is shown.

Do you have the Electron.NET CLI in the same version 23.6.1 also?

Delete the obj/host folder please and try again.

I have the CLI installed
image

Deleting obj/host did not help

You can reproduce the issue in a MRE that you can give us in form of a GitHub repository (such that we only need to clone and open to see the issue appearing on our machines)

I'm on it...

I have stripped the project I am working on and that causing the problem
https://drive.google.com/file/d/1PpT-JREP-1Qp5ViJ6r568BDbIsD6df4e/view?usp=share_link

Video recording
https://drive.google.com/file/d/19wtVQj8AlSFF9rQLtjRG87e0XKNUp2NA/view?usp=share_link

You can see on the video that the splash screen (via electron.manifest.json) is shown, next it disappears but the main window is not shown + 8001 port been opened.
Ignore JIT debug pop-up, I have System.Diagnostics.Debugger.Launch(); in Main.

electronize start /args "--remote-debugging-port=9222" /dotnet-configuration "Release_Windows"
from the Frontend folder as shown in the video.

The first thing that strikes me is that Electron is having trouble accessing the default URL. If I want to start the frontend project alone in Visual Studio, I get error messages.

image

My tip: Remove the SPA Services and integrate Angular manually. You free yourself from this built-in dependency, which always leads to problems. You can find enough tutorials online on how to integrate Angular with ASP.NET Core WITHOUT SPA Services. As soon as the project can be run normally in the browser without electron, your example will work again with Electron.NET.

@GregorBiswanger I'll try it, thanks!

If you have made your changes and it still doesn't work, then you are very welcome to reopen the issue.

I found the problem place in my code. It was this line
Electron.App.On("activate", async () =>
on its execution the app just died somewhere within and there was CONNECTION_RESET.
As soon as I changed the line to Electron.App.On("activate", async _ => i.e. I added named parameter it started to pass execution.