ElectronNET / Electron.NET

:electron: Build cross platform desktop apps with ASP.NET Core (Razor Pages, MVC, Blazor).
https://gitter.im/ElectronNET/community
MIT License
7.26k stars 724 forks source link

Switch to another socket.io for c# lib #381

Closed yukozh closed 1 year ago

yukozh commented 4 years ago

The SocketIoClientDotNet team will no longer maintain their project, and they've hidden their package, that blocks the nuget restore.

GregorBiswanger commented 4 years ago

Yes, that's right and it's a problem. Unfortunately we have not yet found an alternative.

However Electron.NET currently works without problems with the last version of SocketIoClientDotNet.

Or did you have difficulties?

query-wow commented 4 years ago

Good afternoon, i've been reading into this project, looks promising. Might be worth to check perhaps? https://github.com/LadislavBohm/socket.io-client-core

GregorBiswanger commented 4 years ago

We would definitely have to try it out with a prototype.

It currently works with the last SocketIoClientDotNet version.

GregorBiswanger commented 4 years ago

FYI @syedadeel2

syedadeel2 commented 4 years ago

FYI @syedadeel2

No more Sockets I'm near to the solution.

dafergu2 commented 4 years ago

FYI @syedadeel2

No more Sockets I'm near to the solution.

I'd be interested in helping with this. I've seen the bridge connector flake out on me after leaving my app running for a long time and it is the one thing that worries me the most.

What are you looking to swap this out with, @syedadeel2 ?

dafergu2 commented 4 years ago

Good afternoon, i've been reading into this project, looks promising. Might be worth to check perhaps? https://github.com/LadislavBohm/socket.io-client-core

This is also an option to explore: https://github.com/HavenDV/H.Socket.IO/

syedadeel2 commented 4 years ago

FYI @syedadeel2

No more Sockets I'm near to the solution.

I'd be interested in helping with this. I've seen the bridge connector flake out on me after leaving my app running for a long time and it is the one thing that worries me the most.

What are you looking to swap this out with, @syedadeel2 ?

I'll reveal soon once I finish the solution. But no sockets for sure.

sanosdole commented 4 years ago

There is an existing solution for C#/JS interop without websockets: https://github.com/sanosdole/nodeclrhost

If there is any interest in using it, i could provide assistance.

GregorBiswanger commented 4 years ago

@syedadeel2 can you check this please?

sanosdole commented 4 years ago

Easiest way to review the capabilities:

  1. Check out the repository
  2. Go into ~/examples/electron-blazor and run npm run
  3. Read/Debug the dotnet source code for the browser (~/examples/electron-blazor/LocalService) & renderer process (~/examples/electron-blazor/BlazorApp)

Here is an old image from the example code that shows the first debugging of a Blazor App in Electron: Blazor App Debugging

GregorBiswanger commented 4 years ago

@sanosdole Thanks! electron-blazor uses Electron.NET :)

But we will definitely look at this... Possibly, can you even build a small prototype?! Here is a YouTube video that explains something about Electron.NET under the hood: https://www.youtube.com/watch?v=Po-saU_Z6Ws

sanosdole commented 4 years ago

@GregorBiswanger Thanks! electron-blazor uses Electron.NET :)

The prototype steve sanderson did. This one is an example from the nodeclrhost repository. It does not use Electron.NET and also no WASM. It invokes the Electron APIs directly in process using the C#/JS Interop.

Does this qualify as a small prototype? If not I have a large prototype but that is owned by my clients and i may not share this in the public.

I know the inner working of Electron.NET quite well, as we (me and a client of mine) researched it for replacing the GUI layer of a large XAML based application. So i read most of the code of this projects around a year ago. As we required direct renderer memory access for some special 3D controls, I started this project to host a dotnet core CLR through a native node addon.

Edit: I`ll watch the video later this evening when I have time. At first I thought you meant the introductionary Video on how to use electron.

GregorBiswanger commented 4 years ago

@sanosdole everything sounds very exciting.. I will take a closer look at this tonight and how we could take it with us..

how does the communication of classic ASP.NET Core MVC / Razor Pages work out here? They always need a web host to get their HTML pages?!

sanosdole commented 4 years ago

how does the communication of classic ASP.NET Core MVC / Razor Pages work out here? They always need a web host to get their HTML pages?!

I researched this when i started. It is theoretically possible to skip opening a port using an electron resource handler implementation. But to get this working an alternative WebHost implementation is required and that would require some heavy (reverse-)engineering work. Especially making websockets (e.g. Server-Side Blazor) work would be quite an investment.

I never did an example for a MVC app, but i think it would be straight forward when using kestrel.

syedadeel2 commented 4 years ago

@syedadeel2 can you check this please?

This is was my original plan using JSInterop but I'm looking in different solution as I find the performance is not as what I'm expecting when doing a lot of calls. Other thing is that this good when you are app is running the in electron but what we are trying here to controls the electron on startup and hook events at this stage your app isn't loaded in the browser. to resolve this I'm actually testing some different solution and use cases. But good work has been done for "nodeclrhost" and have lot of potentials. Maybe I will combine this in my solution

And I'm trying not to build this especially for Blazor - my scope is to build one for all of-course the SPA/PWA gives the best experiences.

I'll let you know once I'm near to this :)

sanosdole commented 4 years ago

your app isn't loaded in the browser

Well this is not true. The dotnet CLR is hosted by the node process using a native plugin. Everything is in one process and calls are native. We are directly hooking up dotnet code and JS code.

as I find the performance is not as what I'm expecting when doing a lot of calls

The benchmarks in the coreclr-hosting package shows that invoking JS is of course slower than JS itself. (Mostly due to optimizations in the v8) We are talking about 15000000 ops/sec on my machine. That is about 0.66 micro-seconds overhead per JS invocation. The only possible architectural optimization Iยดm seeing is skipping the nodeJS native ABI and directly integrating with the used v8 engine. And this would be tremendous work for not much of an improvement. Am I missing an alternative way to integrate dotnet with JS?

And I'm trying not to build this especially for Blazor

nodeclrhost is a generic node/dotnet interop mechanism first (coreclr-hosting & NodeHostEnvironment projects). It is not bound to Electron or ASP.NET. The Blazor in renderer Process parts are separate projects (electron-blazor-glue & ElectronHostedBlazor projects) that could be moved to another repository.

Also please take a look at the mvc-example branch. It contains a fully working MVC/RazorPages Electron application in ~/examples/electron-mvc. The only thing modified from the default webapp template is the Program.cs.

freosc commented 4 years ago

@syedadeel2 Did you reach any progress on this one? I'm anxious to know cause I need to decide whether to use ElectronJs with or without Electron.net.

GregorBiswanger commented 4 years ago

@freosc You can use Electron.NET without problems. We would change the communication, but without breaking changes here.

freosc commented 4 years ago

@freosc You can use Electron.NET without problems. We would change the communication, but without breaking changes here.

Many thanks for the work you've done to this project already. But can you give me an expected ETA of the new IPC backend? I'll be one of the pioneers to test it ;)

GregorBiswanger commented 4 years ago

@freosc Do you have currently problems with the current one?

I have no time plan, I think the next weeks we have more Infos for you.

freosc commented 4 years ago

The problem I have is the disconnecting issue (Got disconnect! Reason ping timeout). Even with 9.31.1 and the latest SocketIO client. If I leave the app running for a few hours on a test PC without doing anything (actually 2 hours seems to be enough), a disconnect occurs (ping timeout), after that, all communication is broken between browser and .net core mvc app.

syedadeel2 commented 4 years ago

@syedadeel2 Did you reach any progress on this one? I'm anxious to know cause I need to decide whether to use ElectronJs with or without Electron.net.

I'll update you guys soon, Sorry just got caught with COVID-19 stuff within my organization and I'm hardly getting time for me. But let me give you guys some insight I'm working with Edge.js to use In-process method to avoid the Sockets. I'll soon complete the small prototype and share with @GregorBiswanger. Once we agreed we will start working on the full project not sure maybe a separate repo.

sanosdole commented 4 years ago

@syedadeel2 If you are using EdgeJS please consider switching over to nodeclrhost.

We have written nodeclrhost because edge.js is a dead project. It has not been updated for some years now (last commit on official repo is more than 3 years ago) and has no official support for the core clr. There are some forks that might work, but nodeclrhost has a lot more features like a less restrictive interop API based on the dynamic language runtime with support for synchronous JS invocation and invoking any JS code directly from C#.

I also have already done a prototype that is running Electron.NET through nodeclrhost over here. It basically works besides having Exceptions on shutdown and not being tested thoroughly.

I only spend a few hours to write the Electron.NET prototype, so it proves viability. The downsides of in-process communication are the same as for edge.js, it only uses a different interop API. I believe it would be advantageous to merge efforts here, as it is the same thing without a dead project in the middle.

If you are interested in using nodeclrhost instead of edgejs, i could give you some help. I want people to work with nodeclrhost so I can improve its API, documentation and stability.

syedadeel2 commented 4 years ago

@sanosdole I can see what you are saying :) I have forked your nodeclrhost let me try that as well.

syedadeel2 commented 4 years ago

@sanosdole @GregorBiswanger I have sent you guys an invite to join my private repo where I'm pushing the code for the new version. It's not ready yet just a skeleton but just added you guys so we can create the project and think about what to add and what not.

rakista112 commented 4 years ago

@syedadeel2 I could help with mac efforts in the new IPC backend if you invite me to the repo. Our project is invested in Electron.NET and we are facing the disconnect/no-reconnect issue in Mac.

freosc commented 4 years ago

@syedadeel2 Did you reach any progress? What's the plan? If extra help is needed, I'm also willing to do something.

GregorBiswanger commented 4 years ago

@freosc The last few weeks I've been busy with my business. I think I will have time for that in the next few weeks.

syedadeel2 commented 4 years ago

@freosc The last few weeks I've been busy with my business. I think I will have time for that in the next few weeks.

that's why I was wondering where you gone :)

syedadeel2 commented 4 years ago

@sanosdole I'm working on the new repo, and I'm still waiting for you to accept my invite also there is some issue with your nodeclr if you have time we can talk about.

GregorBiswanger commented 1 year ago

๐ŸŽ‰๐Ÿš€ 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!

Yuvix25 commented 7 months ago

Any update on this? Help needed?