IPC appears to be broken on Windows #257

Closed
opened 2026-01-29 16:34:59 +00:00 by claunia · 11 comments
Owner

Originally created by @richardpartridgeflynet on GitHub (Jan 14, 2019).

Originally assigned to: @GregorBiswanger on GitHub.

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

Originally created by @richardpartridgeflynet on GitHub (Jan 14, 2019). Originally assigned to: @GregorBiswanger on GitHub. 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 <Link> 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
claunia added the bug label 2026-01-29 16:34:59 +00:00
Author
Owner

@herefishyfish commented on GitHub (Jan 15, 2019):

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

@herefishyfish commented on GitHub (Jan 15, 2019): I'm getting this too. Any points in the right direction would be amazing.
Author
Owner

@GregorBiswanger commented on GitHub (Jan 15, 2019):

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.

@GregorBiswanger commented on GitHub (Jan 15, 2019): 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.
Author
Owner

@richardpartridgeflynet commented on GitHub (Jan 15, 2019):

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 commented on GitHub (Jan 15, 2019): 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
Author
Owner

@richardpartridgeflynet commented on GitHub (Jan 15, 2019):

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

@richardpartridgeflynet commented on GitHub (Jan 15, 2019): 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
Author
Owner

@theiviaxx commented on GitHub (Mar 12, 2019):

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?

@theiviaxx commented on GitHub (Mar 12, 2019): 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?
Author
Owner

@timothyparez commented on GitHub (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)

@timothyparez commented on GitHub (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)_
Author
Owner

@pedromrpinto commented on GitHub (Apr 22, 2019):

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.

@pedromrpinto commented on GitHub (Apr 22, 2019): 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.
Author
Owner

@theiviaxx commented on GitHub (May 6, 2019):

@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

@theiviaxx commented on GitHub (May 6, 2019): @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
Author
Owner

@raloverafs commented on GitHub (May 8, 2019):

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

@raloverafs commented on GitHub (May 8, 2019): We're having @richardpartridgeflynet 's issue as well. When will we be able to update to a release with @pedromrpinto 's PR? Thanks
Author
Owner

@GregorBiswanger commented on GitHub (May 16, 2019):

Fixed! Big thanks to @pedromrpinto!

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

@GregorBiswanger commented on GitHub (May 16, 2019): Fixed! **Big thanks** to @pedromrpinto! The next few days will be the next big Electron.NET update released.
Author
Owner

@dafergu2 commented on GitHub (Sep 27, 2019):

@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.

@dafergu2 commented on GitHub (Sep 27, 2019): @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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#257