MagicOnion
MagicOnion copied to clipboard
How to setup MagicOnion Unity for using Grpc.Net.Client;
I read the document, and saw that MagicOnion client on unity can use Grpc.Net.Client; But I don't find any document showing how to do that. Does anyone know how?
Sorry for the confusing documentation. Currently on Unity you need to use C-core gRPC library. https://github.com/Cysharp/MagicOnion#support-for-unity-client
Nope I found this in code: #if USE_GRPC_NET_CLIENT
and some I done it today my client can connect to MagicOnion Server through Grpc.Net.Client; and Grpc.Net.Client.Web;
Is this part you're asking for? https://github.com/grpc/grpc/tree/master/src/csharp/experimental#unity
Hi, @binhnguyen86 Could you please share the way how you use the Grpc.Net.Client in Unity? I just try on my computer but seems not working at all...
Sorry for the confusion. USE_GRPC_NET_CLIENT
is code that will be needed in the future.
Currently, you need to use Grpc.Core (C-core) in your Unity (Standalone, iOS, Android ...) application.
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Hi guys @neuecc @mayuki,
I am working on the concept for the future project with Unity + .NET. I was going to use RPC, and MagicOnion seems an excellent option. I actively use your MsgPack and UniTask libs in my projects, and I love them. Not a single complaint for several years.
But regarding this lib (usage for Unity) ,I expect some serious issues to come up. Even though gRPC extended Grpc.Core support for one year - the core component of MagicOnion for Unity seems to be deprecated. (alt url https://grpc.io/blog/grpc-csharp-future/).
This lib - grpc-dotnet might seem as alternative. But the author clearly stated there would be no steps further to support Unity: https://github.com/grpc/grpc-dotnet/issues/1309#issuecomment-850303082
And it seems to me that it might require significant efforts to make Unity and Grpc.Net.Client work together. It would require a fork of grpc-dotnet that works on a custom HTTP/2 client, which also works in Unity.
So my question is: Do you have an envisioning of how the problem can be resolved for MagicOnion and Unity? I know you guys use the MagicOnion package for many of your projects, I have been reading your blog, so perhaps you have some ideas or plans.
P.S. I have some controversial thoughts regarding Grpc.Core deprecation. They state in the article that it is widely used even by Google. So perhaps some option might appear.
(screenshot form here)
But on the other hand, EOF was supposed to take a place in May 2022, and nothing has changed since now :)
I just wanted to know your opinion before making a decision.
You can use this with MagicOnion and Unity to skip over needing a native gRPC client at all. It uses UnityWebRequest
: https://github.com/Cysharp/GrpcWebSocketBridge
@mwegner I feel lack of details in the doc about how exactly does it work:
- If it uses UnityWebRequest why does it reference
Grpc.Net.Clinet
? - What modifications are applied to that lib so it can be used for
GrpcWebSocketBridget
? - If I need it for iOS, I can use
Grpc.Net.Clinet
lib without any modifications? - It mentions what I should reference
System.Memory
from nuget package - does it mean it should be linked with 'non-Uniy' implementation ofSystem.Memory
? It should work - but, also might be a problem later on.
It seems to me that the lib is under active development right now - do you think it is a production-ready?
I switched an in-development project to use it, in order to get rid of the native plugin requirement. Stability seems fine! It's actually a little more robust when it comes to connection drops, at least from the POV of the server.
I imagine it needs some of the Grpc libraries for their types more than anything functional, but I don't know offhand. I used an unmodified library, including iOS builds. One big reason I tried this bridge out as soon as it was available was that this project will eventually ship on consoles, and I wasn't looking forward to building our own gRPC native plugins there--and now we don't have to. (Thanks, Cysharp folks!)
Which version of Unity provides a System.Memory
implementation? I've always had to bring in some external DLL, for both 2020 LTS and 20201 LTS.
It wasn't hard or time consuming to swap this project from MagicOnion over native gRPC plugin to MagicOnion over this websocket bridge (I think it was <1hr of work, but I did it awhile ago). I'd recommend poking around a toy project implementation yourself to see if it meets your needs!
Since gRPC for .NET (C-core) development has been discontinued, we are also looking into ways to use grpc-dotnet (Grpc.Net.Client) in Unity apps.
One option is waiting for Unity runtime upgrade to .NET 6/7 (or later) so that we can use grpc-dotnet without modification, but this may take some time.
The other option is to port SocketsHttpHandler
from .NET Core and combine it with TLS library to use HTTP/2 transport. This is currently being tested at PoC phase.
WebSocket bridging certainly works, but its primary target is the WebGL platform and environments that require native-independence. Due to the overhead and small differences in behavior of bridges, we would prefer to use HTTP/2 transport on standalone and mobile platforms as much as possible.
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Since gRPC for .NET (C-core) development has been discontinued, we are also looking into ways to use grpc-dotnet (Grpc.Net.Client) in Unity apps.
One option is waiting for Unity runtime upgrade to .NET 6/7 (or later) so that we can use grpc-dotnet without modification, but this may take some time. The other option is to port
SocketsHttpHandler
from .NET Core and combine it with TLS library to use HTTP/2 transport. This is currently being tested at PoC phase.
@mayuki I am also looking into using http2 transport for grpc as I would like to avoid wrapping the transport in something else again. I also have little confidence Unity will ship .NET 6/7 anytime soon. As for your PoC, is this work available somewhere to look into / check out?