Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to setup MagicOnion Unity for using Grpc.Net.Client; #501

Closed
binhnguyen86 opened this issue Feb 22, 2022 · 14 comments
Closed

How to setup MagicOnion Unity for using Grpc.Net.Client; #501

binhnguyen86 opened this issue Feb 22, 2022 · 14 comments
Labels
stale stale not updated issue & pr

Comments

@binhnguyen86
Copy link

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?

@mayuki
Copy link
Member

mayuki commented Feb 22, 2022

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

@binhnguyen86
Copy link
Author

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;

@sableangle
Copy link
Contributor

@sableangle
Copy link
Contributor

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...

@mayuki
Copy link
Member

mayuki commented May 9, 2022

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.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2022

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.

@github-actions github-actions bot added the stale stale not updated issue & pr label Aug 8, 2022
@kondratov-saritasa
Copy link

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: grpc/grpc-dotnet#1309 (comment)

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.
image
(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.

@mwegner
Copy link

mwegner commented Aug 11, 2022

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

@kondratov-saritasa
Copy link

@mwegner I feel lack of details in the doc about how exactly does it work:
image

  • 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 of System.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?

@mwegner
Copy link

mwegner commented Aug 11, 2022

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!

@github-actions github-actions bot removed the stale stale not updated issue & pr label Aug 12, 2022
@mayuki
Copy link
Member

mayuki commented Aug 12, 2022

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.

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added the stale stale not updated issue & pr label Nov 11, 2022
@doctorseus
Copy link

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?

@github-actions github-actions bot removed the stale stale not updated issue & pr label Nov 18, 2022
@github-actions
Copy link
Contributor

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the stale stale not updated issue & pr label May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale stale not updated issue & pr
Projects
None yet
Development

No branches or pull requests

6 participants