mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-04-06 06:02:33 +00:00
Socket IO disconnect leads to no IPC #510
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kylethomas320 on GitHub (Jun 11, 2020).
Originally assigned to: @GregorBiswanger on GitHub.
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:
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!
@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..
@kylethomas320 commented on GitHub (Jun 12, 2020):
Cool! When will Electron.NET 9.31.1 be released?
@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
Does this
reasonhelp with solving the bug?I'd appreciate the help!
@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.
@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.
@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.
@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.
@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
@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.
@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):
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:
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!
@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
@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!
@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.
@kylethomas320 commented on GitHub (Jan 16, 2021):
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!
@danatcofo commented on GitHub (Jan 25, 2021):
I believe this is fixed as of 11.5.1. @GregorBiswanger
@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.
@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.
@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:
I believe this is due to the disconnect/connect, but I'm not sure.
@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!