Socket Disconnection Error #540

Closed
opened 2026-01-29 16:42:25 +00:00 by claunia · 18 comments
Owner

Originally created by @AykutToprak on GitHub (Jul 21, 2020).

Originally assigned to: @GregorBiswanger on GitHub.

  • Version: 9.31.2
  • CLI Version: 9.31.2
  • Target: .NET Core 3.1

Got disconnect! Reason: transport close
ASP.NET Core Application connected... global.electronsocket fVcXgik5tZt05sn7AAAB 2020-07-21T13:23:13.319Z
stdout: BridgeConnector connected!

As it showed above socket are disconnected and reconnected again. This caused problem for IPC Listeners. I guess they are somehow removed.
Is there any workaround to solve this? @GregorBiswanger

Similar issue : #442 #428

Originally created by @AykutToprak on GitHub (Jul 21, 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**: 9.31.2 * **CLI Version**: 9.31.2 <!-- Which version of .NET Core and Node.js are you using (if applicable)? --> <!-- What target are you building for? --> * **Target**: .NET Core 3.1 <!-- Enter your issue details below this comment. --> <!-- If you want, you can donate to increase issue priority (https://donorbox.org/electron-net) --> Got disconnect! Reason: transport close ASP.NET Core Application connected... global.electronsocket fVcXgik5tZt05sn7AAAB 2020-07-21T13:23:13.319Z stdout: BridgeConnector connected! As it showed above socket are disconnected and reconnected again. This caused problem for IPC Listeners. I guess they are somehow removed. Is there any workaround to solve this? @GregorBiswanger Similar issue : #442 #428
claunia added the help wantedbug labels 2026-01-29 16:42:25 +00:00
Author
Owner

@rakista112 commented on GitHub (Jul 29, 2020):

I've been facing this issue too. One minute all IPC works properly, then a transport error appears and it doesn't try to reconnect.
I'm using ElectronNET.CLI Version: 9.31.2.0
Here is the error that's being displayed.

Got disconnect! Reason: transport error
ASP.NET Core Application connected... global.electronsocket dZkuRoGtHpejWwBYAAAC 2020-07-29T11:42:47.602Z
stdout: BridgeConnector connected!

stdout: dbug: Microsoft.AspNetCore.Server.Kestrel[10]
      Connection id "0HM1JMHGH414A" disconnecting.
dbug: Microsoft.AspNetCore.Server.Kestrel[10]
      Connection id "0HM1JMHGH4149" disconnecting.

stdout: dbug: Microsoft.AspNetCore.Server.Kestrel[2]
      Connection id "0HM1JMHGH4149" stopped.
dbug: Microsoft.AspNetCore.Server.Kestrel[2]
      Connection id "0HM1JMHGH414A" stopped.

stdout: dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7]
      Connection id "0HM1JMHGH4149" sending FIN because: "The Socket transport's send loop completed gracefully."

stdout: dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7]
      Connection id "0HM1JMHGH414A" sending FIN because: "The Socket transport's send loop completed gracefully."

@rakista112 commented on GitHub (Jul 29, 2020): I've been facing this issue too. One minute all IPC works properly, then a transport error appears and it doesn't try to reconnect. I'm using ElectronNET.CLI Version: 9.31.2.0 Here is the error that's being displayed. ``` Got disconnect! Reason: transport error ASP.NET Core Application connected... global.electronsocket dZkuRoGtHpejWwBYAAAC 2020-07-29T11:42:47.602Z stdout: BridgeConnector connected! stdout: dbug: Microsoft.AspNetCore.Server.Kestrel[10] Connection id "0HM1JMHGH414A" disconnecting. dbug: Microsoft.AspNetCore.Server.Kestrel[10] Connection id "0HM1JMHGH4149" disconnecting. stdout: dbug: Microsoft.AspNetCore.Server.Kestrel[2] Connection id "0HM1JMHGH4149" stopped. dbug: Microsoft.AspNetCore.Server.Kestrel[2] Connection id "0HM1JMHGH414A" stopped. stdout: dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7] Connection id "0HM1JMHGH4149" sending FIN because: "The Socket transport's send loop completed gracefully." stdout: dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7] Connection id "0HM1JMHGH414A" sending FIN because: "The Socket transport's send loop completed gracefully." ```
Author
Owner

@GregorBiswanger commented on GitHub (Aug 14, 2020):

Normally the socket connection should restore the registrations. Have you lost these?

@GregorBiswanger commented on GitHub (Aug 14, 2020): Normally the socket connection should restore the registrations. Have you lost these?
Author
Owner

@AykutToprak commented on GitHub (Aug 20, 2020):

Socket connection is restored however IPC Listeners are not. Commitications between front-end and back-end are completely disconnected

@AykutToprak commented on GitHub (Aug 20, 2020): Socket connection is restored however IPC Listeners are not. Commitications between front-end and back-end are completely disconnected
Author
Owner

@Gaulomatic commented on GitHub (Oct 15, 2020):

I am encountering this issue as well. On some Windows 10 machines this leads to the situation where the app can not quit itself anymore. The main process is killed, but all remaining Electron processes as well as the ASP.NET core process run until they are force killed by any means (e.g. TaskManager).

EDIT:
Here is an example if you invoke Electron.WindowManager.BrowserWindows.First().Maximize(); after the disconnect happened:

image
@Gaulomatic commented on GitHub (Oct 15, 2020): I am encountering this issue as well. On _some_ Windows 10 machines this leads to the situation where the app can not quit itself anymore. The main process is killed, but all remaining Electron processes as well as the ASP.NET core process run until they are force killed by any means (e.g. TaskManager). EDIT: Here is an example if you invoke `Electron.WindowManager.BrowserWindows.First().Maximize();` after the disconnect happened: <img width="696" alt="image" src="https://user-images.githubusercontent.com/7631781/96060927-298c3280-0e92-11eb-90f3-0d398cdec747.png">
Author
Owner

@IIiKoBiT commented on GitHub (Jan 17, 2021):

When will it be fixed?
This is very critical for me. Is there a way to temporarily fix this?

@IIiKoBiT commented on GitHub (Jan 17, 2021): When will it be fixed? This is very critical for me. Is there a way to temporarily fix this?
Author
Owner

@IIiKoBiT commented on GitHub (Jan 19, 2021):

@GregorBiswanger
I didn't wait for an answer, I cloned the whole project and built it. The disconnect problem is gone and everything works well. But any resources stopped working for me, there are no icons and images, what could it be?

@IIiKoBiT commented on GitHub (Jan 19, 2021): @GregorBiswanger I didn't wait for an answer, I cloned the whole project and built it. The disconnect problem is gone and everything works well. But any resources stopped working for me, there are no icons and images, what could it be?
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

@JollyRoger91 commented on GitHub (Feb 16, 2021):

@danatcofo Unfortunately, this bug is not fixed yet.

I'm facing this issue now too and I'm using the latest release 11.5.1

As @Gaulomatic pointed out, it seems that this issue depends on the machine. Our Software runs on 30-40 machines without any issue, but on 4 machines this issue happens frequently. I do not see any obvious difference between the machines which work and the machines which won't work.

  • All are physical machines (no VMs)
  • All running Windows 10 (1903 to 2004)
  • It happens irregularly (Sometimes it fails after 10 Minutes, sometimes it fails after a couple of hours (max 5))

@IIiKoBiT I don't quite understand how this bug can be fixed if I compile this project myself? Did you make additional make any changes to the code?

@JollyRoger91 commented on GitHub (Feb 16, 2021): @danatcofo Unfortunately, this bug is not fixed yet. I'm facing this issue now too and I'm using the latest release **11.5.1** As @Gaulomatic pointed out, it seems that this issue depends on the machine. Our Software runs on **30-40** machines without any issue, but on **4** machines this issue happens frequently. I do not see any obvious difference between the machines which work and the machines which won't work. - All are physical machines (no VMs) - All running Windows 10 (1903 to 2004) - It happens irregularly (Sometimes it fails after 10 Minutes, sometimes it fails after a couple of hours (max 5)) @IIiKoBiT I don't quite understand how this bug can be fixed if I compile this project myself? Did you make additional make any changes to the code?
Author
Owner

@GregorBiswanger commented on GitHub (Jul 2, 2021):

I can hardly reproduce it. We need support.

Here is a video of how you can install the missing features yourself and submit them as a pull request: https://youtu.be/Po-saU_Z6Ws

Please also test it with you.

@GregorBiswanger commented on GitHub (Jul 2, 2021): I can hardly reproduce it. We need support. Here is a video of how you can install the missing features yourself and submit them as a pull request: https://youtu.be/Po-saU_Z6Ws Please also test it with you.
Author
Owner

@GregorBiswanger commented on GitHub (Jul 2, 2021):

We are currently also using a .NET library to be able to communicate with Nodejs Socket.io, which has long been deprecated.

We need a new one that will continue to be maintained and will also work with the current Socket.io version. Can someone help us? We are also happy to do this together.

@GregorBiswanger commented on GitHub (Jul 2, 2021): We are currently also using a .NET library to be able to communicate with Nodejs Socket.io, which has long been deprecated. We need a new one that will continue to be maintained and will also work with the current Socket.io version. Can someone help us? We are also happy to do this together.
Author
Owner

@GregorBiswanger commented on GitHub (Jul 2, 2021):

The talk here is of SocketIoClientDotNet
https://github.com/Quobject/SocketIoClientDotNet/

@GregorBiswanger commented on GitHub (Jul 2, 2021): The talk here is of **SocketIoClientDotNet** https://github.com/Quobject/SocketIoClientDotNet/
Author
Owner

@tub5 commented on GitHub (Jul 5, 2021):

@GregorBiswanger the socket.io-client-csharp package seems to be fairly similar. As long as we specify that the EIO is 3 (socket.io 2.x) rather than the default 4 (socket.io 3.x 4.x). It seems to be updated fairly regularly.

@tub5 commented on GitHub (Jul 5, 2021): @GregorBiswanger the [socket.io-client-csharp](https://github.com/doghappy/socket.io-client-csharp/) package seems to be fairly similar. As long as we specify that the EIO is 3 (socket.io 2.x) rather than the default 4 (socket.io 3.x 4.x). It seems to be updated fairly regularly.
Author
Owner

@pvenky commented on GitHub (Jul 9, 2021):

I can hardly reproduce it. We need support.

Here is a video of how you can install the missing features yourself and submit them as a pull request: https://youtu.be/Po-saU_Z6Ws

Please also test it with you.

I'm able to reproduce this problem fairly consistently when calling BrowserWindow.GetBoundsAsync. When I programmatically resize the window, I can call GetBoundsAsync and there seems to be no problem. However, when I call the same method after a user resize event, i.e., inside an event handler for the BrowserWindow.OnResize, then the await window.GetBoundsAsync() never returns and eventually there is a socket disconnect.

@pvenky commented on GitHub (Jul 9, 2021): > I can hardly reproduce it. We need support. > > Here is a video of how you can install the missing features yourself and submit them as a pull request: https://youtu.be/Po-saU_Z6Ws > > Please also test it with you. I'm able to reproduce this problem fairly consistently when calling `BrowserWindow.GetBoundsAsync`. When I programmatically resize the window, I can call `GetBoundsAsync` and there seems to be no problem. However, when I call the same method after a user resize event, i.e., inside an event handler for the `BrowserWindow.OnResize`, then the `await window.GetBoundsAsync()` never returns and eventually there is a socket disconnect.
Author
Owner

@dbphoton commented on GitHub (Oct 12, 2021):

Is there any way to handled that issue manually from code?

@dbphoton commented on GitHub (Oct 12, 2021): Is there any way to handled that issue manually from code?
Author
Owner

@Krizzzn commented on GitHub (Jul 7, 2022):

I'm encountering the same issue and I think I have pinned it down to being caused by a large json (~500KB) document being transmitted from the backend to the Electron App. What's weird is, that different computers seem to have different limits here.
Maybe this helps.

@Krizzzn commented on GitHub (Jul 7, 2022): I'm encountering the same issue and I think I have pinned it down to being caused by a large json (~500KB) document being transmitted from the backend to the Electron App. What's weird is, that different computers seem to have different limits here. Maybe this helps.
Author
Owner

@jamieyello commented on GitHub (Nov 30, 2022):

In my case the solution was as simple as making sure my System.Threading.Timer was disposed.

Not disposing it caused this error.

If it's any use to a developer, here's a (not isolated) function where it would occur. I create a Timer to update my Blazor component every 50 milliseconds, excluding the using caused the bug.

I'll try to reproduce it later on shareable code, but it seems like more of a user error issue than an electron one.

    public async Task<bool> Decrypt(VaultItem item) {
        var hmac = JsonConvert.DeserializeObject<byte[]>(item.Description.Properties["HMAC"]);
        var name = (string)item.Values["File Name"].Data;
        var size = (long)item.Values["Size"].Data;
        var key = Convert.FromBase64String((string)item.Values["Key"].Data);
        var out_path = await folder.SaveAsFile("Export File From Vault", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), name));


        if (out_path == null) return false;
        var enc_path = ad.State.Vaults.Active.Files.GetEncryptedFilePath(hmac);
        using var input_stream = File.OpenRead(enc_path);

        try
        {
            bool canceled = false;
            is_processing = true;
            process_text = "Decrypting " + name;
            await InvokeAsync(StateHasChanged);
            int previous_progress;

            // remove the using here to cause the bug
            using var timer = new System.Threading.Timer(async _ =>
            {
                previous_progress = progress;
                progress = (int)((input_stream.Position * 100 / size));
                if (cancel)
                {
                    if (!canceled) input_stream.Close();
                    canceled = true;
                }
                if (progress != previous_progress) await InvokeAsync(StateHasChanged);
            }, null, 0, 100);

            await ad.State.Vaults.Active.Files.Export(input_stream, hmac, key, out_path);
            is_done = true;
            is_processing = false;
            await InvokeAsync(StateHasChanged);
            snack_bar.Add($"Exported file to disk.", Severity.Success);
        }
        catch (Exception ex) {
            if (!cancel) snack_bar.Add($"Failed to decrypt file: {ex.Message}", Severity.Error);
        }

        is_done = false;
        cancel = false;
        progress = 0;
        process_text = null;
        is_processing = false;
        return true;
    }
@jamieyello commented on GitHub (Nov 30, 2022): In my case the solution was as simple as making sure my System.Threading.Timer was disposed. Not disposing it caused this error. If it's any use to a developer, here's a (not isolated) function where it would occur. I create a Timer to update my Blazor component every 50 milliseconds, excluding the `using` caused the bug. I'll try to reproduce it later on shareable code, but it seems like more of a user error issue than an electron one. ``` public async Task<bool> Decrypt(VaultItem item) { var hmac = JsonConvert.DeserializeObject<byte[]>(item.Description.Properties["HMAC"]); var name = (string)item.Values["File Name"].Data; var size = (long)item.Values["Size"].Data; var key = Convert.FromBase64String((string)item.Values["Key"].Data); var out_path = await folder.SaveAsFile("Export File From Vault", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), name)); if (out_path == null) return false; var enc_path = ad.State.Vaults.Active.Files.GetEncryptedFilePath(hmac); using var input_stream = File.OpenRead(enc_path); try { bool canceled = false; is_processing = true; process_text = "Decrypting " + name; await InvokeAsync(StateHasChanged); int previous_progress; // remove the using here to cause the bug using var timer = new System.Threading.Timer(async _ => { previous_progress = progress; progress = (int)((input_stream.Position * 100 / size)); if (cancel) { if (!canceled) input_stream.Close(); canceled = true; } if (progress != previous_progress) await InvokeAsync(StateHasChanged); }, null, 0, 100); await ad.State.Vaults.Active.Files.Export(input_stream, hmac, key, out_path); is_done = true; is_processing = false; await InvokeAsync(StateHasChanged); snack_bar.Add($"Exported file to disk.", Severity.Success); } catch (Exception ex) { if (!cancel) snack_bar.Add($"Failed to decrypt file: {ex.Message}", Severity.Error); } is_done = false; cancel = false; progress = 0; process_text = null; is_processing = false; return true; } ```
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!
Author
Owner

@arthurvalentereis commented on GitHub (Dec 18, 2023):

Hello everyone, I have this problem, my visual studio is .NET8 but I just cloned the repository, followed the steps and started the project. Can someone help me? Could .net8 be the cause of the problem?

ElectronHostHook handling started...
Invoke electron.cmd - in dir: C:\Git\Infis\electron.net-api-demos\obj\Host\node_modules\.bin
electron.cmd "..\..\main.js"

Electron Socket IO Port: 8000
Electron Socket started on port 8000 at 127.0.0.1
ASP.NET Core Port: 8001
stdout: Use Electron Port: 8000

ASP.NET Core Application connected... global.electronsocket RcG020kd_wqGtineAAAA 2023-12-18T19:22:00.715Z
ASP.NET Core Application connected... global.electronsocket RcG020kd_wqGtineAAAA 2023-12-18T19:22:03.168Z
ASP.NET Core Application connected... global.electronsocket RcG020kd_wqGtineAAAA 2023-12-18T19:22:03.187Z
Got disconnect! Reason: transport close
Got disconnect! Reason: ping timeout

Solved: Guys, I didn't see it, but my Electron CLI was outdated, I updated it using command dotnet tool update ElectronNET.CLI -g and now it works

@arthurvalentereis commented on GitHub (Dec 18, 2023): Hello everyone, I have this problem, my visual studio is .NET8 but I just cloned the repository, followed the steps and started the project. Can someone help me? Could .net8 be the cause of the problem? ```cmd ElectronHostHook handling started... Invoke electron.cmd - in dir: C:\Git\Infis\electron.net-api-demos\obj\Host\node_modules\.bin electron.cmd "..\..\main.js" Electron Socket IO Port: 8000 Electron Socket started on port 8000 at 127.0.0.1 ASP.NET Core Port: 8001 stdout: Use Electron Port: 8000 ASP.NET Core Application connected... global.electronsocket RcG020kd_wqGtineAAAA 2023-12-18T19:22:00.715Z ASP.NET Core Application connected... global.electronsocket RcG020kd_wqGtineAAAA 2023-12-18T19:22:03.168Z ASP.NET Core Application connected... global.electronsocket RcG020kd_wqGtineAAAA 2023-12-18T19:22:03.187Z Got disconnect! Reason: transport close Got disconnect! Reason: ping timeout ``` Solved: Guys, I didn't see it, but my Electron CLI was outdated, I updated it using command `dotnet tool update ElectronNET.CLI -g ` and now it works ✅
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#540