Socket IO disconnect leads to no IPC #510

Closed
opened 2026-01-29 16:41:31 +00:00 by claunia · 20 comments
Owner

Originally created by @kylethomas320 on GitHub (Jun 11, 2020).

Originally assigned to: @GregorBiswanger on GitHub.

  • Version: 8.31.2
  • .NET Core version 3.1
  • Target: Windows 10

When running my Electron.NET application for a while, sometimes a few minutes, sometimes up to half an hour, I get the following messages printed in my console:

Got disconnect!  
ASP.NET Core Application connected... global.electronsocket C2zRUaIlrhDjLVRMAAAE 2020-06-11T17:49:54.749Z
stdout: BridgeConnector connected!

After which no IPC can be processed, leaving my app in a frozen state in which just the JS works.

This seems to occur at random times, with no actual reason leading to the cause (atleast I can't figure out what the cause is).

Can somebody help me out with this?

Thanks in advance!

Originally created by @kylethomas320 on GitHub (Jun 11, 2020). Originally assigned to: @GregorBiswanger on GitHub. <!-- Please search existing issues to avoid creating duplicates. --> <!-- Which version of Electron.NET CLI and API are you using? --> <!-- Please always try to use latest version before report. --> * **Version**: 8.31.2 <!-- Which version of .NET Core and Node.js are you using (if applicable)? --> * .NET Core version 3.1 <!-- What target are you building for? --> * **Target**: Windows 10 <!-- Enter your issue details below this comment. --> When running my Electron.NET application for a while, sometimes a few minutes, sometimes up to half an hour, I get the following messages printed in my console: ``` Got disconnect! ASP.NET Core Application connected... global.electronsocket C2zRUaIlrhDjLVRMAAAE 2020-06-11T17:49:54.749Z stdout: BridgeConnector connected! ``` After which no IPC can be processed, leaving my app in a frozen state in which just the JS works. This seems to occur at random times, with no actual reason leading to the cause (atleast I can't figure out what the cause is). Can somebody help me out with this? Thanks in advance!
claunia added the bug label 2026-01-29 16:41:31 +00:00
Author
Owner

@GregorBiswanger commented on GitHub (Jun 11, 2020):

We will now release Electron.NET 9.31.1.. it would be great if you could test the new version and give us feedback again..

@GregorBiswanger commented on GitHub (Jun 11, 2020): We will now release Electron.NET 9.31.1.. it would be great if you could test the new version and give us feedback again..
Author
Owner

@kylethomas320 commented on GitHub (Jun 12, 2020):

Cool! When will Electron.NET 9.31.1 be released?

@kylethomas320 commented on GitHub (Jun 12, 2020): Cool! When will Electron.NET 9.31.1 be released?
Author
Owner

@kylethomas320 commented on GitHub (Jun 15, 2020):

I upgraded to 9.31.1 half an hour back, and have now seen the first appearance of a BridgeConnector disconnect

Got disconnect! Reason: transport close
ASP.NET Core Application connected... global.electronsocket Y_qkuJxS3w9qW8lvAAAB 2020-06-15T07:07:44.955Z
stdout: BridgeConnector connected!

Does this reason help with solving the bug?

I'd appreciate the help!

@kylethomas320 commented on GitHub (Jun 15, 2020): I upgraded to 9.31.1 half an hour back, and have now seen the first appearance of a BridgeConnector disconnect ``` Got disconnect! Reason: transport close ASP.NET Core Application connected... global.electronsocket Y_qkuJxS3w9qW8lvAAAB 2020-06-15T07:07:44.955Z stdout: BridgeConnector connected! ``` Does this `reason` help with solving the bug? I'd appreciate the help!
Author
Owner

@kylethomas320 commented on GitHub (Jun 20, 2020):

I'm still in need for a fix for this bug, is there no way to just reset the existing event listeners after a reset? That would at least suffice as a temporary fix. Right now the entire backend just hangs due to the crashed communication.

@kylethomas320 commented on GitHub (Jun 20, 2020): I'm still in need for a fix for this bug, is there no way to just reset the existing event listeners after a reset? That would at least suffice as a temporary fix. Right now the entire backend just hangs due to the crashed communication.
Author
Owner

@iwate commented on GitHub (Jun 20, 2020):

same too. on 8.31.2 and 9.31.1
8.31.1 not disconnect. it seems good.

@iwate commented on GitHub (Jun 20, 2020): same too. on 8.31.2 and 9.31.1 8.31.1 not disconnect. it seems good.
Author
Owner

@MopsieX commented on GitHub (Jun 24, 2020):

This happens to me randomly. Sometimes it happens within 5 seconds of the app launching and sometimes after an hour.

@MopsieX commented on GitHub (Jun 24, 2020): This happens to me randomly. Sometimes it happens within 5 seconds of the app launching and sometimes after an hour.
Author
Owner

@Velorien commented on GitHub (Jun 30, 2020):

@GregorBiswanger is there a way to manually restore the connection in this situation? I'm experiencing similar issues on Windows, but unfortunately they happen at random, except when the machine is put in sleep mode and sleeps for a while, in which case it's almost guaranteed that upon waking the pc up, there will be no IPC.

@Velorien commented on GitHub (Jun 30, 2020): @GregorBiswanger is there a way to manually restore the connection in this situation? I'm experiencing similar issues on Windows, but unfortunately they happen at random, except when the machine is put in sleep mode and sleeps for a while, in which case it's almost guaranteed that upon waking the pc up, there will be no IPC.
Author
Owner

@MopsieX commented on GitHub (Jul 3, 2020):

I found a possible work around however it isn't great.
You can create a Ping function in Javascript to send a Ping message through the IPC every few seconds.
setInterval(function () { ipcRenderer.send('Ping', "ping"); }, 10000);
Then in C# you can create a new task that checks how long ago the last ping was. If the ping was longer than x seconds recreate the menu bar. Recreating the menu bar makes it work again.
However when the disconnect happens the Electron.Net Javascript API loses a reference to the window. This is fine if you don't call any BrowserWindow functions. If you do call a function you will get an error saying something like "A JavaScript error occurred in the main process
Uncaught Exception:
TypeError: Cannot read property '{the function you called}' of undefined
at Socket.
" in the browserWindows.js file
I created a new issue for Electron.Net losing the browserWindow references here https://github.com/ElectronNET/Electron.NET/issues/442

@MopsieX commented on GitHub (Jul 3, 2020): I found a possible work around however it isn't great. You can create a Ping function in Javascript to send a Ping message through the IPC every few seconds. `setInterval(function () { ipcRenderer.send('Ping', "ping"); }, 10000);` Then in C# you can create a new task that checks how long ago the last ping was. If the ping was longer than x seconds recreate the menu bar. Recreating the menu bar makes it work again. However when the disconnect happens the Electron.Net Javascript API loses a reference to the window. This is fine if you don't call any BrowserWindow functions. If you do call a function you will get an error saying something like "A JavaScript error occurred in the main process Uncaught Exception: TypeError: Cannot read property '{the function you called}' of undefined at Socket.<anonymous> " in the browserWindows.js file I created a new issue for Electron.Net losing the browserWindow references here [https://github.com/ElectronNET/Electron.NET/issues/442](https://github.com/ElectronNET/Electron.NET/issues/442)
Author
Owner

@GregorBiswanger commented on GitHub (Jul 6, 2020):

Hey Community, we have released version 9.31.2 with the electron-builder fix! In addition, I have improved the socket problems again and updated to Electron 9.0.5.

@GregorBiswanger commented on GitHub (Jul 6, 2020): Hey Community, we have released version 9.31.2 with the electron-builder fix! In addition, I have improved the socket problems again and updated to Electron 9.0.5.
Author
Owner

@kylethomas320 commented on GitHub (Jul 6, 2020):

Great news! I will check it out tomorrow and throw some tests at it.

@kylethomas320 commented on GitHub (Jul 6, 2020): Great news! I will check it out tomorrow and throw some tests at it.
Author
Owner

@kylethomas320 commented on GitHub (Jul 6, 2020):

Just a quick update, I decided to update it this evening to give it a quick check. I noticed that the disconnects still occur after a while.. see log:

Got disconnect! Reason: transport close
ASP.NET Core Application connected... global.electronsocket weNao5_nXogqt850AAAB 2020-07-06T20:15:14.537Z
stdout: BridgeConnector connected!
stdout: info: HeftruckManager.Helper.IPCHandler[0]
Got disconnect! Reason: transport close
ASP.NET Core Application connected... global.electronsocket nbnPgVAXknJRMVLLAAAC 2020-07-06T20:22:52.717Z
stdout: BridgeConnector connected!
stdout: info: HeftruckManager.Helper.IPCHandler[0]

These two disconnects happened within 10 minutes of each other after i left my laptop idle for a while.
Is there a way for me to provide a more detailed error, such that fixing it becomes easier?

I'll keep an eye on the disconnects tomorrow and see if anything changes.
Thanks for the hard work on the updates though!

@kylethomas320 commented on GitHub (Jul 6, 2020): Just a quick update, I decided to update it this evening to give it a quick check. I noticed that the disconnects still occur after a while.. see log: ``` Got disconnect! Reason: transport close ASP.NET Core Application connected... global.electronsocket weNao5_nXogqt850AAAB 2020-07-06T20:15:14.537Z stdout: BridgeConnector connected! stdout: info: HeftruckManager.Helper.IPCHandler[0] Got disconnect! Reason: transport close ASP.NET Core Application connected... global.electronsocket nbnPgVAXknJRMVLLAAAC 2020-07-06T20:22:52.717Z stdout: BridgeConnector connected! stdout: info: HeftruckManager.Helper.IPCHandler[0] ``` These two disconnects happened within 10 minutes of each other after i left my laptop idle for a while. Is there a way for me to provide a more detailed error, such that fixing it becomes easier? I'll keep an eye on the disconnects tomorrow and see if anything changes. Thanks for the hard work on the updates though!
Author
Owner

@GregorBiswanger commented on GitHub (Jul 6, 2020):

A reconnect shouldn't be bad .. the only important thing is that the events continue to work .. everything else works?

I once made a contribution video .. if necessary you can debug yourself and see why?
https://youtu.be/Po-saU_Z6Ws

@GregorBiswanger commented on GitHub (Jul 6, 2020): A reconnect shouldn't be bad .. the only important thing is that the events continue to work .. everything else works? I once made a contribution video .. if necessary you can debug yourself and see why? https://youtu.be/Po-saU_Z6Ws
Author
Owner

@kylethomas320 commented on GitHub (Jul 6, 2020):

Aha, my apologies.. I misunderstood as to the fact that it would not disconnect at all anymore. In the meanwhile I made a similar construction as @MopsieX described, so I hadn't tested your reconnection fix yet.

I tested it yet again just now, and unfortunately it seems that the events are still removed upon disconnect.
I'll look into the contribution video tomorrow, thanks for the heads up!

@kylethomas320 commented on GitHub (Jul 6, 2020): Aha, my apologies.. I misunderstood as to the fact that it would not disconnect at all anymore. In the meanwhile I made a similar construction as @MopsieX described, so I hadn't tested your reconnection fix yet. I tested it yet again just now, and unfortunately it seems that the events are still removed upon disconnect. I'll look into the contribution video tomorrow, thanks for the heads up!
Author
Owner

@DelpireNI commented on GitHub (Jan 15, 2021):

@kylethomas320 Did you ever get a robust work around with regards to this? I am still experiencing losing my events when a disconnect occurs.

@DelpireNI commented on GitHub (Jan 15, 2021): @kylethomas320 Did you ever get a robust work around with regards to this? I am still experiencing losing my events when a disconnect occurs.
Author
Owner

@kylethomas320 commented on GitHub (Jan 16, 2021):

@kylethomas320 Did you ever get a robust work around with regards to this? I am still experiencing losing my events when a disconnect occurs.

Basically my solution for this is sending a heartbeat to the frontend every 5 seconds. If I don't receive the heartbeat after 5 seconds, I kill all listeners and restart these. Definitely not the best solution, and still at times it doesn't manage to restore these connections, but it occurs less often than before. I'm still hoping the development team manages to somehow fix this bug. Good luck!

@kylethomas320 commented on GitHub (Jan 16, 2021): > @kylethomas320 Did you ever get a robust work around with regards to this? I am still experiencing losing my events when a disconnect occurs. Basically my solution for this is sending a heartbeat to the frontend every 5 seconds. If I don't receive the heartbeat after 5 seconds, I kill all listeners and restart these. Definitely not the best solution, and still at times it doesn't manage to restore these connections, but it occurs less often than before. I'm still hoping the development team manages to somehow fix this bug. Good luck!
Author
Owner

@danatcofo commented on GitHub (Jan 25, 2021):

I believe this is fixed as of 11.5.1. @GregorBiswanger

@danatcofo commented on GitHub (Jan 25, 2021): I believe this is fixed as of 11.5.1. @GregorBiswanger
Author
Owner

@Delpire commented on GitHub (Jan 26, 2021):

@kylethomas320 This was causing me issues with my menu items. They would stop working. My solution was to create an ElectronHostHook that would create the menu items for me, and if I needed to pass any information, I can do that by setting up electron IPCs and using the javascript interop to make the calls. Electron's IPCs seem more robust than the Socket libraries Electron .NET is using. Its unfortunate, and removes a huge benefit that we get from Electron .NET, but it seems more reliable.

@danatcofo - I don't know what changes were made as of 11.5.1, but when I tested this last Tuesday or so by building from the master branch, I was still seeing the issue. Looking at the changelog, the only change related to this seems to have been your fix, which had not resolved the issue on my VM.

@Delpire commented on GitHub (Jan 26, 2021): @kylethomas320 This was causing me issues with my menu items. They would stop working. My solution was to create an ElectronHostHook that would create the menu items for me, and if I needed to pass any information, I can do that by setting up electron IPCs and using the javascript interop to make the calls. Electron's IPCs seem more robust than the Socket libraries Electron .NET is using. Its unfortunate, and removes a huge benefit that we get from Electron .NET, but it seems more reliable. @danatcofo - I don't know what changes were made as of 11.5.1, but when I tested this last Tuesday or so by building from the master branch, I was still seeing the issue. Looking at the changelog, the only change related to this seems to have been your fix, which had not resolved the issue on my VM.
Author
Owner

@danatcofo commented on GitHub (Jan 26, 2021):

No, I still plan on looking into the menu issue. It's on top of my free time list as I expect it will impact my own project. However the general socket issues are fixed around Ipc connectivity with the browser windows. That's what my fix targeted as mentioned in the other ticket.

At the moment I'm heads down getting the first release done for my project as it's due to be delivered by next week. I hope to get to the menu issue prior to next week but deadlines are deadlines.

@danatcofo commented on GitHub (Jan 26, 2021): No, I still plan on looking into the menu issue. It's on top of my free time list as I expect it will impact my own project. However the general socket issues are fixed around Ipc connectivity with the browser windows. That's what my fix targeted as mentioned in the other ticket. At the moment I'm heads down getting the first release done for my project as it's due to be delivered by next week. I hope to get to the menu issue prior to next week but deadlines are deadlines.
Author
Owner

@Delpire commented on GitHub (Jan 26, 2021):

@danatcofo , @GregorBiswanger - a new issues I discovered with the disconnect is a potential memory leak. I ran my application all night, and it disconnected and reconnected a ton of times. Eventually I got this message:

(node:15580) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 window-all-closed listeners added to app [App]. Use emitter.setMaxListeners() to increase limit.

I believe this is due to the disconnect/connect, but I'm not sure.

@Delpire commented on GitHub (Jan 26, 2021): @danatcofo , @GregorBiswanger - a new issues I discovered with the disconnect is a potential memory leak. I ran my application all night, and it disconnected and reconnected a ton of times. Eventually I got this message: ``` (node:15580) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 window-all-closed listeners added to app [App]. Use emitter.setMaxListeners() to increase limit. ``` I believe this is due to the disconnect/connect, but I'm not sure.
Author
Owner

@GregorBiswanger commented on GitHub (Mar 28, 2023):

🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉

With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!

@GregorBiswanger commented on GitHub (Mar 28, 2023): 🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉 With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#510