OpenAvikom / mr-grpc-unity

Use gRPC to send protocol buffer messages from and to Unity
16 stars 5 forks source link

Error: Cannot connect to all addresses #2

Closed EricVoll closed 2 years ago

EricVoll commented 2 years ago

Hi @aleneum

thanks for providing this code. I tried to build the app and deploy it to the HL2 emulator and the real HL2. The demo works in Unity in Playmode, but doesn't when built for the emulator or the real HL2.

My setup is: Win10, with WSL2 where the gRPC server was running (port forwarding etc. is working and validated) Unity Version: tried with 2019.4.35f1 and 2020.3.28.f1, Currently downloading 2021 and 2022 to try with them as well. In the Unity Case:

In all fail-cases the error message was:

Sending message 'Hello from Unity!' to IP:9091
[...]
RpcException: Status(StatusCode=Unavailable, Detail="failed to connect to all addresses")
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.Internal.AsyncCall`2[TRequest,TResponse].UnaryCall (TRequest msg) [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.Calls.BlockingUnaryCall[TRequest,TResponse] (Grpc.Core.CallInvocationDetails`2[TRequest,TResponse] call, TRequest req) [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse] (Grpc.Core.Method`2[TRequest,TResponse] method, System.String host, Grpc.Core.CallOptions options, TRequest request) [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.Interceptors.InterceptingCallInvoker.<BlockingUnaryCall>b__3_0[TRequest,TResponse] (TRequest req, Grpc.Core.Interceptors.ClientInterceptorContext`2[TRequest,TResponse] ctx) [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.Interceptors.Interceptor+BlockingUnaryCallContinuation`2[TRequest,TResponse].Invoke (TRequest request, Grpc.Core.Interceptors.ClientInterceptorContext`2[TRequest,TResponse] context) [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.ClientBase+ClientBaseConfiguration+ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse] (TRequest request, Grpc.Core.Interceptors.ClientInterceptorContext`2[TRequest,TResponse] context, Grpc.Core.Interceptors.Interceptor+BlockingUnaryCallContinuation`2[TRequest,TResponse] continuation) [0x00000] in <00000000000000000000000000000000>:0 
  at Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse] (Grpc.Core.Method`2[TRequest,TResponse] method, System.String host, Grpc.Core.CallOptions options, TRequest request) [0x00000] in <00000000000000000000000000000000>:0 
  at Proto.Services.HelloService+HelloServiceClient.SayHello (Proto.Messages.HelloMessage request, Grpc.Core.CallOptions options) [0x00000] in <00000000000000000000000000000000>:0 
  at Proto.Services.HelloService+HelloServiceClient.SayHello (Proto.Messages.HelloMessage request, Grpc.Core.Metadata headers, System.Nullable`1[T] deadline, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at HelloMessageSender.SendMessage () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Events.InvokableCall.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.Toolkit.UI.Interactable.SendOnClick (Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer pointer) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.Toolkit.UI.Interactable.TriggerOnClick (System.Boolean force) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.Toolkit.PhysicalPressEventRouter.OnHandPressTriggered () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Events.InvokableCall.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.Toolkit.UI.PressableButton.UpdatePressedState (System.Single pushDistance) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.Toolkit.UI.PressableButton.UpdateTouch () [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.Toolkit.UI.PressableButton.Update () [0x00000] in <00000000000000000000000000000000>:0 

The link.xml file is there, I made sure that the server/WSL portforwarding etc. works by launching the send python script from another PC and sending the request to the same IP address. My guess is that the IL2CPP compiler and/or code-stripping breaks something.

Do you have any idea what could cause the issues?

Thanks, Eric

EricVoll commented 2 years ago

Update: I just changed the build in Unity to build for ARM (not ARM64) and then in Visual Studio to deploy to HL2 with ARM64 and now it worked! Leaving this note here in case somebody has the same issue. (Also make sure to open the port in the firewall etc.)