pusher / pusher-websocket-unity

Pusher Channels Unity Client Library
MIT License
27 stars 20 forks source link

Pusher on exe build error #31

Closed Sterling-Malory-Archer closed 2 years ago

Sterling-Malory-Archer commented 2 years ago

I have developed a desktop app using pusher that when it receives an event it takes a photo and sends it to an email:

 private void PusherOnConnected(object sender)
    {
        Debug.Log("Connected");
        channel.Bind("TakePicture", (dynamic data) =>
        {
            shouldTakePhoto = true;

            try
            {
                var jTest = JsonConvert.DeserializeObject<dynamic>(data.ToString());
                try
                {

                    var testEmail = JsonConvert.DeserializeObject<dynamic>(data.data.ToString());

                    emailTo = testEmail.email.ToString();

                } catch (Exception ex)
                {
                    errorText.text = "Houston we have a problem: " + ex.Message.ToString();
                }
            }
            catch (Exception ex)
            {
                errorText.text = "Houston we have a problem: " + ex.Message.ToString();
            }
        });
    }

This works fine in the editor, however when I build it for exe, and I trigger the pusher event, nothing fires. Looking at the log files on desktop I get this:

NullReferenceException: Object reference not set to an instance of an object.
  at System.Linq.Expressions.Interpreter.LightLambda.MakeRunDelegateCtor (System.Type delegateType) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Linq.Expressions.Interpreter.LightLambda.GetRunDelegateCtor (System.Type delegateType) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Linq.Expressions.Interpreter.LightDelegateCreator.CreateDelegate () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Linq.Expressions.Expression`1[TDelegate].Compile (System.Boolean preferInterpretation) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.CallSite`1[T].MakeUpdateDelegate () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.CallSite`1[T].GetUpdateDelegate (T& addr) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.CallSite`1[T]..ctor (System.Runtime.CompilerServices.CallSiteBinder binder) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.CallSite`1[T].Create (System.Runtime.CompilerServices.CallSiteBinder binder) [0x00000] in <00000000000000000000000000000000>:0 
  at PusherClient.EventEmitter.EmitDynamicEvent (System.String eventName, System.String data) [0x00000] in <00000000000000000000000000000000>:0 
  at PusherClient.EventEmitter.EmitEvent (System.String eventName, PusherClient.PusherEvent data) [0x00000] in <00000000000000000000000000000000>:0 
  at PusherClient.Pusher.PusherClient.IPusher.EmitChannelEvent (System.String channelName, System.String eventName, PusherClient.PusherEvent data) [0x00000] in <00000000000000000000000000000000>:0 
  at PusherClient.Connection.websocket_MessageReceived (System.Object sender, WebSocket4Net.MessageReceivedEventArgs e) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Diagnostics.DataReceivedEventHandler.Invoke (System.Object sender, System.Diagnostics.DataReceivedEventArgs e) [0x00000] in <00000000000000000000000000000000>:0 
  at WebSocket4Net.Command.Text.ExecuteCommand (WebSocket4Net.WebSocket session, WebSocket4Net.WebSocketCommandInfo commandInfo) [0x00000] in <00000000000000000000000000000000>:0 
  at WebSocket4Net.WebSocket.OnDataReceived (System.Byte[] data, System.Int32 offset, System.Int32 length) [0x00000] in <00000000000000000000000000000000>:0 
  at WebSocket4Net.WebSocket.client_DataReceived (System.Object sender, SuperSocket.ClientEngine.DataEventArgs e) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Diagnostics.DataReceivedEventHandler.Invoke (System.Object sender, System.Diagnostics.DataReceivedEventArgs e) [0x00000] in <00000000000000000000000000000000>:0 
  at SuperSocket.ClientEngine.ClientSession.OnDataReceived (System.Byte[] data, System.Int32 offset, System.Int32 length) [0x00000] in <00000000000000000000000000000000>:0 
  at SuperSocket.ClientEngine.AuthenticatedStreamTcpSession.OnDataRead (System.IAsyncResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at System.AsyncCallback.Invoke (System.IAsyncResult ar) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Display+DisplaysUpdatedDelegate.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.Run (System.Threading.Tasks.Task task, System.Boolean canInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetResult (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream+<StartOperation>d__58.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Display+DisplaysUpdatedDelegate.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetResult (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.AsyncProtocolRequest+<StartOperation>d__23.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Display+DisplaysUpdatedDelegate.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetResult (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.AsyncProtocolRequest+<ProcessOperation>d__24.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Display+DisplaysUpdatedDelegate.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetResult (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.AsyncProtocolRequest+<InnerRead>d__25.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Display+DisplaysUpdatedDelegate.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetResult (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream+<InnerRead>d__66.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Display+DisplaysUpdatedDelegate.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.TaskFactory`1+FromAsyncTrimPromise`1[TResult,TInstance].Complete (TInstance thisRef, System.Func`3[T1,T2,TResult] endMethod, System.IAsyncResult asyncResult, System.Boolean requiresSynchronization) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.TaskFactory`1+FromAsyncTrimPromise`1[TResult,TInstance].CompleteFromAsyncResult (System.IAsyncResult asyncResult) [0x00000] in <00000000000000000000000000000000>:0 
  at System.AsyncCallback.Invoke (System.IAsyncResult ar) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Xml.Schema.XdrBuilder+XdrEndChildFunction.Invoke (System.Xml.Schema.XdrBuilder builder) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Xml.Schema.XdrBuilder+XdrEndChildFunction.Invoke (System.Xml.Schema.XdrBuilder builder) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0 
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
System.Diagnostics.DataReceivedEventHandler:Invoke(Object, DataReceivedEventArgs)

I am using Unity 2019.4.24f1.

Any help is kindly appreciated

twomedia commented 2 years ago

If you're using IL2CPP you can't use the channel.Bind functions with dynamic types. Use one of the other overrides without dynamic types. See: https://github.com/pusher/pusher-websocket-unity#3-il2cpp-extra-steps

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you'd like this issue to stay open please leave a comment indicating how this issue is affecting you. Thank you.