heroiclabs / nakama-unity

Unity client for Nakama server.
https://heroiclabs.com/docs/unity-client-guide
Other
407 stars 75 forks source link

C# - [BUG] Calling RPC without socket causes NullReferenceException #131

Open PrzemekAcram opened 2 years ago

PrzemekAcram commented 2 years ago

Hello,

I would like to report a bug.

Sending more than 9k characters with IClient's RpcAsync method causes NullReferenceException.

Example method which throws exception:

    async void sendLongString (Client nakamaClient, string serverKey)
{
    string longString = "buubvubqou5623vt78";

    for (int i = 0; i < 9; ++i)
    {
        longString += longString;
    }

    string messageToSend = "{\"longString\": \"" + longString + "\"}";

    var response = await nakamaClient.RpcAsync (serverKey, rpcName, messageToSend); // <- NullReferenceException.
    string result = response.Payload;

    Debug.Log ("Response: " + result);
}

There is no issue If we do the same by the socket (socket.RpcAsync (rpcName, messageToSend);. Sending request from Postman works as well.

Exception:

NullReferenceException: Object reference not set to an instance of an object Nakama.HttpRequestAdapter+d8.MoveNext () (at <3930c37f95f7433fa71239b42efdd1f6>:0) --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () (at <9577ac7a62ef43179789031239ba8798>:0) Nakama.ApiClient+d68.MoveNext () (at <3930c37f95f7433fa71239b42efdd1f6>:0) --- End of stack trace from previous location where exception was thrown --- Nakama.RetryInvoker+d__6`1[T].MoveNext () (at <3930c37f95f7433fa71239b42efdd1f6>:0) --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0) System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0) (....)

Best, Przemek