Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPC appears to be broken on Windows #204

Closed
richardpartridgeflynet opened this issue Jan 14, 2019 · 11 comments
Closed

IPC appears to be broken on Windows #204

richardpartridgeflynet opened this issue Jan 14, 2019 · 11 comments
Assignees
Labels
Milestone

Comments

@richardpartridgeflynet
Copy link

Hi,

I'm working on a proof of concept (Windows not Linux/Mac) prior to us using Electon.NET in an upcoming project and I'm having an issue with the IPC between the main and renderer processes. I can get the IPC working but only very briefly, after a little time messages like this will begin scrolling up the console:

ASP.NET Core Application connected... global.electronsocket cQS8pxM3WoqXUD2IAAAB 2019-01-14T16:17:47.132Z
stdout: BridgeConnector connected!

These messages are generated about every 30s until the program is closed. Once the first of these messages has appeared, IPC between the main and rendered processes stops.

Please note that I raised a very similar issue (number 12) on the electron.net-api-demos project. This issue was closed because the demos code was not created with the latest version of the Electron.NET API but I don't think that explanation applies to this issue.

Here's a minimal set of instructions that should let you reproduce the issue starting with a clean Win 2012 R2 VM:

Install dotnet-sdk-2.2.102 (issue also shows up with sdk 2.1)
Install Node 10.15.0 LTS
Create a new app with dotnet new mvc
Install ElectronNET.API 0.0.11
Install ElectronNET.CLI 0.0.11
Add some basic IPC between main and rendered processes, I copied the code Gregor added in his Getting Started video on YouTube

Start the app and try out the IPC, note that it works. Leave the app for a while until one of the BridgeConnector messages appears, re-try the IPC and note that it no longer works.

Note that you may have to edit the Views\Shared_Layout.cshtml file to remove the integrity="..." attributes from the tags as Electron doesn't handle those well.

Please let me know if you have any suggestions as to what might be going on or if you need any more info to help diagnose the issue.

Thanks,

Richard

@GregorBiswanger GregorBiswanger self-assigned this Jan 14, 2019
@herefishyfish
Copy link

I'm getting this too. Any points in the right direction would be amazing.

@GregorBiswanger
Copy link
Member

Hi,
this is unfortunately a known problem: #106

When the connection is rebuilt, all event listeners are lost. I need a solution with Socket.IO.

@richardpartridgeflynet
Copy link
Author

Hi Gregor,

I should probably have been clearer when I raised this issue, when I said 'Leave the app for a while' I meant leave it for a minute, two at the most rather than a long period such as overnight.

I guess the question is what causes the connection to be rebuilt after such a short period and every 30s thereafter?

Regards,

Richard

@richardpartridgeflynet
Copy link
Author

Hi Gregor,

Below is the console output from my app (detailed above). From the timestamps you can see that the connection messages appear roughly 30s apart. The stdout: ping messages are from my IPC code. There is also a message about window-all-closed listeners near the end, does that provide any insight?

C:\Users\Richard\source\electron-net>electronize start
Start Electron Desktop Application...
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\Richard\source\electron-net>dotnet publish -r win-x64 --output "C:\Users\Richard\source\electron-net\obj\Host\bin"
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
  Restore completed in 299.13 ms for C:\Users\Richard\source\electron-net\electron-net.csproj.
  electron-net -> C:\Users\Richard\source\electron-net\bin\Debug\netcoreapp2.2\win-x64\electron-net.dll
  electron-net -> C:\Users\Richard\source\electron-net\bin\Debug\netcoreapp2.2\win-x64\electron-net.Views.dll
  electron-net -> C:\Users\Richard\source\electron-net\obj\Host\bin\
C:\Users\Richard\source\electron-net>
Skip npm install, because node_modules directory exists in: C:\Users\Richard\source\electron-net\obj\Host\node_modules
Invoke electron.cmd - in dir: C:\Users\Richard\source\electron-net\obj\Host\node_modules\.bin
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\Richard\source\electron-net\obj\Host\node_modules\.bin>electron.cmd "..\..\main.js"
stdout: Use Electron Port: 8000
stdout: Hosting environment: Production
Content root path: C:\Users\Richard\source\electron-net\obj\Host\bin\
Now listening on: http://0.0.0.0:8001
Application started. Press Ctrl+C to shut down.
ASP.NET Core Application connected... global.electronsocket 7BjrlJikGM6icX_pAAAA 2019-01-15T17:18:17.824Z
stdout: BridgeConnector connected!
stdout: ping
stdout: ping
stdout: ping
stdout: ping
ASP.NET Core Application connected... global.electronsocket QX-RIfR3At_F-ayWAAAB 2019-01-15T17:18:48.954Z
stdout: BridgeConnector connected!
ASP.NET Core Application connected... global.electronsocket mkF598t6sKCqHugwAAAC 2019-01-15T17:19:19.985Z
stdout: BridgeConnector connected!
ASP.NET Core Application connected... global.electronsocket DlLR094vXGe-iMCZAAAD 2019-01-15T17:19:51.021Z
stdout: BridgeConnector connected!
ASP.NET Core Application connected... global.electronsocket KW91dbAJd9k_1rxdAAAE 2019-01-15T17:20:22.021Z
stdout: BridgeConnector connected!
ASP.NET Core Application connected... global.electronsocket BBmqHXfom5d9W-JgAAAF 2019-01-15T17:20:53.057Z
stdout: BridgeConnector connected!
ASP.NET Core Application connected... global.electronsocket WVnXyxevDrTH5AgOAAAG 2019-01-15T17:21:24.068Z
stdout: BridgeConnector connected!
ASP.NET Core Application connected... global.electronsocket vIhal4Pcz66AGXVvAAAH 2019-01-15T17:22:20.100Z
stdout: BridgeConnector connected!
ASP.NET Core Application connected... global.electronsocket uP_6opXOtOKGfK2zAAAI 2019-01-15T17:22:51.129Z
stdout: BridgeConnector connected!
ASP.NET Core Application connected... global.electronsocket v6bD0GlW5J0_eP37AAAJ 2019-01-15T17:23:22.174Z
(node:3624) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 window-all-closed listeners added. Use emitter.setMaxListeners() to increase limit
stdout: BridgeConnector connected!
ASP.NET Core Application connected... global.electronsocket rS64X4zpyGx8XdmTAAAK 2019-01-15T17:23:53.217Z
stdout: BridgeConnector connected!
C:\Users\Richard\source\electron-net\obj\Host\node_modules\.bin>

Regards,
Richard

@theiviaxx
Copy link

I also get this, though not on this cadence. it will just happen at some point in the application lifetime, i cant seem to narrow it down to a specific event.

Im not sure if this is the wrong way, but is there something i can do on the asp side to "re-connect" everything?

@timothyparez
Copy link

timothyparez commented Mar 20, 2019

I get the same issue on Ubuntu 16.04
So the classic example of opening a dialog, on one end I have:

Electron.IpcMain.On("select-directory", async args => { ... }

and on the other end:

document.getElementById("select-directory").addEventListener("click", () => {
        ipcRenderer.send("select-directory");
    });
<input type="button" id="select-directory" title="Select Folder" value="select"/>

If I start the application and do not click that button the disconnect will happen
about 30 seconds after the window has loaded.

ASP.NET Core Application connected... global.electronsocket cZPwH6dBGyb8MFdrAAAC 2019-03-20T07:33:23.882Z

However, if I click that button as soon as the window has loaded, the dialog is shown,
and I can show it multiple times without any issues. I can even let it sit there for 10 minutes
click it and it will still work.

So it seems that once that initial "contact" has been made the connection is kept alive.

Edit: I have determined that in my case the disconnect happens because the "server" side was doing a lot of work at startup (service instances being created for dependency injection). This does not take away the issue of course, but thought it might be good to mention (and I should update my design)

@pedromrpinto
Copy link
Contributor

I had a similar issue. Everytime the socket reconnects Tray, Globalshortcuts, etc, lose the concat between js and C#. The pull request #233 (FIX application hangs after socket reconnect) shoud fix that problem.

@theiviaxx
Copy link

@pedromrpinto I am using your PR changes and so far so good 👍 It does report the Bridge disconnect message, but everything still works as expected

@raloverafs
Copy link

We're having @richardpartridgeflynet 's issue as well. When will we be able to update to a release with @pedromrpinto 's PR? Thanks

@GregorBiswanger GregorBiswanger added this to the 0.0.12 milestone May 16, 2019
@GregorBiswanger
Copy link
Member

Fixed! Big thanks to @pedromrpinto!

The next few days will be the next big Electron.NET update released.

@dafergu2
Copy link
Contributor

@GregorBiswanger I'm still getting these messages in the log. Functionality still seems to be working, but I'm a bit concerned about the msg:

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 window-all-closed listeners added. Use emitter.setMaxListeners() to increase limit

Is this a false positive or is there something that needs to change to prevent a leak? I'm more than happy to debug.

I'm running with .net core 3.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants