Comments (8)
I have come across this issue too, this exception is thrown in the latest version (version 6)
I've downgraded to the following version and it works.
MagicOnion.Client 5.1.8
MagicOnion.Shared 5.1.8
MagicOnion.Server 5.1.8
MagicOnion.Server.HttpGateway 5.1.8
MagicOnion.Serialization.MemoryPack 5.1.8-preview
from grpcwebsocketbridge.
I have also encountered that issue, but the solution is simple.
Change:
var channel = GrpcChannel.ForAddress(address, new GrpcChannelOptions()
{
HttpHandler = new GrpcWebSocketBridgeHandler()
});
To:
var channel = GrpcChannel.ForAddress(address, new GrpcChannelOptions()
{
HttpHandler = new GrpcWebSocketBridgeHandler(true)
});
from grpcwebsocketbridge.
Thanks it works as expected with the changes.
from grpcwebsocketbridge.
While this solve this problem I don't think that issue is fully resolved since this parameter is undocumented. It easy to just follow basic example from Readme without realizing that this is and why it is needed. @mayuki
from grpcwebsocketbridge.
from grpcwebsocketbridge.
We just released version 1.3.0.
Could you please check if the problem occurs in the new version?
from grpcwebsocketbridge.
Here is my test results.
Environment: Windows 11. (All nugets latest, magiconion and grpcwebsocketbridge.
Application: Net MAUI Blazor Hybrid
Connection from Windows: Successful with new upgrade.
Case 1: Connecting from Windows MAUI App to MagicOnionGrpcServer
Channel Configuration code:
GrpcChannel channel?;
if (OperatingSystem.IsWindows())
{
var httpHandler = new GrpcWebSocketBridgeHandler(); **//Note there was no need to forceWebSocketMode, though it works with that as sell**
channel = GrpcChannel.ForAddress(baseUri, new GrpcChannelOptions
{
HttpHandler = httpHandler,
MaxReceiveMessageSize = 20 * 1024 * 1024, // 10 MB
MaxSendMessageSize = 10 * 1024 * 1024, // 10 MB
});
}
Results: Working as expected.
Case 2: Connecting from Android MAUI App to MagicOnionGrpcServer (Same App but running Android Build)
if (OperatingSystem.IsAndroid())
{
var httpHandler = new GrpcWebSocketBridgeHandler(true); //Does not work with any either true or false for forceWebSocket
channel = GrpcChannel.ForAddress(baseUri, new GrpcChannelOptions
{
HttpHandler = httpHandler,
MaxReceiveMessageSize = 20 * 1024 * 1024, // 10 MB
MaxSendMessageSize = 10 * 1024 * 1024, // 10 MB
});
}
[chromium] [INFO:CONSOLE(1)] "The channel configuration isn't valid on Android devices. The channel is configured to use HttpClientHandler and Android's native HTTP/2 library. gRPC isn't fully supported by Android's native HTTP/2 library and it can cause runtime errors. To fix this problem, either configure the channel to use SocketsHttpHandler, or add <UseNativeHttpHandler>false</UseNativeHttpHandler> to the app's project file. For more information, see https://aka.ms/aspnet/grpc/android.
[chromium] at Grpc.Net.Client.GrpcChannel.CreateInternalHttpInvoker(HttpMessageHandler handler) in /_/src/Grpc.Net.Client/GrpcChannel.cs:line 501
[chromium] at Grpc.Net.Client.GrpcChannel..ctor(Uri address, GrpcChannelOptions channelOptions) in /_/src/Grpc.Net.Client/GrpcChannel.cs:line 161
[chromium] at Grpc.Net.Client.GrpcChannel.ForAddress(Uri address, GrpcChannelOptions channelOptions) in /_/src/Grpc.Net.Client/GrpcChannel.cs:line 697
[chromium] at Grpc.Net.Client.GrpcChannel.ForAddress(String address, GrpcChannelOptions channelOptions) in /_/src/Grpc.Net.Client/GrpcChannel.cs:line 667
[chromium] at Insights.Services.Client.NativeGrpcClientChannel.GetGrpcChannel(String baseUri) in D:\Trade\InsightsOnDaprAspire\src\Services\Client\NativeGrpcClientChannel.cs:line 45
[chromium] at Insights.Core.Client.Grpc.GrpcClients.EquitiesGrpcServiceClient.GetClient() in D:\Trade\InsightsOnDaprAspire\src\Core\Client\Grpc\GrpcClients\EquitiesGrpcServiceClient.cs:line 68
[chromium] at Insights.Core.Client.Grpc.GrpcClients.EquitiesGrpcServiceClient..ctor(IGrpcClient nativeGrpcClient, IConfiguration configuration, ILogger`1 logger, IBlazorUserManager blazorUserManager) in D:\Trade\InsightsOnDaprAspire\src\Core\Client\Grpc\GrpcClients\EquitiesGrpcServiceClient.cs:line 31
[chromium] at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args)
[chromium] at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
[chromium] at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[chromium] at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier)
[chromium] at System.Collections.Concurrent.ConcurrentDictionary`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceIdentifier, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[Microsoft.Extensions.DependencyInjection.ServiceProvider.ServiceAccessor, Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].GetOrAdd(ServiceIdentifier key, Func`2 valueFactory)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
[chromium] at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
[chromium] at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass9_0.<CreatePropertyInjector>g__Initialize|1(IServiceProvider serviceProvider, IComponent component)
[chromium] at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType, IComponentRenderMode callerSpecifiedRenderMode, Nullable`1 parentComponentId)
[chromium] at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame[] frames, Int32 frameIndex, Int32 parentComponentId)
[chromium] at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)
[chromium] at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
[chromium] at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
[chromium] at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
[chromium] at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
[chromium] at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
[chromium] at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
[chromium] at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()", source: https://0.0.0.0/_framework/blazor.webview.js (1)
[GPUAUX] [AUX]GuiExtAuxCheckAuxPath:663: Null anb
Result: Does not work on MAUI Android App. with above configuration.
Workaround/Perhaps right way to create channel specific to MAUI
After a little research and guidance from a reply of @JamesNK, I figured out that correct way to create a channel on MAUI app should be.
if (OperatingSystem.IsAndroid())
{
var httpHandler = new GrpcWebSocketBridgeHandler(true); //Works with both true/false
channel = GrpcChannel.ForAddress(baseUri, new GrpcChannelOptions
{
HttpClient = new HttpClient(httpHandler), //Observe that we are passing HttpClient with GrpcWebSocketBridgeHandler
MaxReceiveMessageSize = 20 * 1024 * 1024, // 10 MB
MaxSendMessageSize = 10 * 1024 * 1024, // 10 MB
});
}
I belive current build 1.3 has fixed the existing issues and the issue specific to MAUI relates to the way we need to provision the channel is specific to Android.
Thanks for such great tools and libraries.
Love from New Delhi!
from grpcwebsocketbridge.
I have forwarded it to a separate Issue because it is a different problem than this one that has been reported.
from grpcwebsocketbridge.
Related Issues (14)
- Is Magic Onion supported? HOT 3
- How to set up envoy? HOT 4
- Custom SSL Cert HOT 3
- Why MagicOnionSampleApp.Shared is Targeting netstandard 2.0? HOT 3
- WebGL biuld doesn't work HOT 2
- It is possible to use one websocket for all services? HOT 1
- How to use it with yarp? HOT 1
- Unity WebGL libC error. HOT 1
- MagicOnion 6.0 and GrpcWebSocketBridge: Buffer is not large enough for header HOT 1
- Error: The underlying HTTP transport must be a SocketsHttpHandler HOT 4
- Channel is not available in Android MAUI application HOT 1
- Error when serving WebGL build externally rather than through server code HOT 2
- 1.1.0 broke MagicOnionService HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grpcwebsocketbridge.