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!
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..
Cool! When will Electron.NET 9.31.1 be released?
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!
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.
same too. on 8.31.2 and 9.31.1
8.31.1 not disconnect. it seems good.
This happens to me randomly. Sometimes it happens within 5 seconds of the app launching and sometimes after an hour.
@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.
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
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.
Great news! I will check it out tomorrow and throw some tests at it.
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!
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
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!