altmp / altv-issues

Issues and roadmap for alt:V project
92 stars 17 forks source link

RPC AnswerWithError not received on clientside (C#) #2248

Closed riffy closed 4 months ago

riffy commented 4 months ago

Description of the problem

Using C# on both client (AsyncRessource) and server side (AsyncRessource), an emitted AnswerWithError, is not retrieved by the client

Also tested on Release: alt:V Server 16.0.127 (release) , alt:V Launcher 16.0.30

Logs in order:

Reproduction steps

Client:

public class SomeRequest (string value) : IMValueConvertibe {
    // Some Adapter Code
    public string Value { get; set; } = value;
}

public class ClientScript {

    public static void Initialize() {
        Alt.OnScriptRPCAnswer += HandleRPCAnswer;
        Log.Debug("ClientScript", "Initialized");
        SomeRequest test = new ("Hello from Client");
        ushort answerId = Alt.EmitRPC("TestEvent", test);
        Log.Debug("Test", $"Fired RPC {answerId}");
    }

    private static void HandleRPCAnswer(ushort answerId, object answer, string answerError) {
        try {
            Log.Debug("Test", $"Received an rpc answer for id {answerId}");
            Log.Debug("Test", $"answer: {JsonSerializer.Serialize(answer)}");
            Log.Debug("Test", $"error: {answerError}");
        }
        catch (Exception ex) {
            Log.Error("Test", "Exception during handling of answer:");
            Log.Error(Test", $"{ex.Message}");
        }
    }
}

Server


public class ScriptClass :  IScript {

    public static void Initialize() {
        AltAsync.OnScriptRpc += Test;
    }

    private static async Task Test(IScriptRPCEvent scriptRpcEvent, IPlayer target, string name, object[] args, ushort answerId) {
        Log.Debug("Test", "OnScriptRPC Fired: ");
        Log.Debug("scriptRpcEvent.WillAnswer", $"{scriptRpcEvent.WillAnswer()}");
        Log.Debug("target.Id", $"{target.Id}");
        Log.Debug("name", $"{name}");
        Log.Debug("answerId", $"{answerId}");
        Log.Debug("args", $"{JsonSerializer.Serialize(args)}");
        bool res = scriptRpcEvent.AnswerWithError("Hello from the other side");
        Log.Debug("answered ? ", $"{res}");
    }

Expected behaviour

Expected HandleRPCAnswer on clientside to handle errors.

Additional context

Client Nugets:

<ItemGroup>
    <PackageReference Include="AltV.Net.Client" Version="16.0.7" />
    <PackageReference Include="AltV.Net.Client.Async" Version="16.0.7" />
  </ItemGroup>

Server nugets:

<ItemGroup>
        <PackageReference Include="AltV.Net" Version="16.0.7" />
        <PackageReference Include="AltV.Net.Async" Version="16.0.7" />
        <PackageReference Include="AltV.Net.Resources.Chat.Api" Version="16.0.7" />
        <PackageReference Include="AltV.Net.Shared" Version="16.0.7" />
        <PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
        <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
        <PackageReference Include="MongoDB.Entities" Version="23.0.1" />
        <PackageReference Include="RestSharp" Version="110.2.0" />
    </ItemGroup>

Operating system

Windows

Version

alt:V Server 16.0.0-dev.255 (dev) , alt:V build #16.0.0-dev.255, branch dev

Crashdump ID

No response

Confirmation of issue's presence

Doxoh commented 4 months ago

@riffy should be fixed with 16.0.8 and 16.0.0-dev.24.

Pls confirm and close then

riffy commented 4 months ago

While trying to confirm the fix, it seems that i can't load the new Nugets, even though the exptected and actual hash is correct :

Client:

[14:14:27] Game version: 3095 on EGS
[14:14:27][Warning] System update WebApp took too much time to execute. 21 ms
[14:38:04] Connect 127.0.0.1 7788 
[14:38:04] Finished downloading all resources
[14:38:04] Download finished
[14:38:04] Downloaded and validated resource muxt succesfully
[14:38:04] Initializing CoreCLR
[14:38:04] Fetching NuGet altv.net.client
[14:38:05] Fetching NuGet altv.net.capi
[14:38:05] Fetching NuGet altv.net.shared
[14:38:06] Validating Host
[14:38:06] Validating NuGet package AltV.Net.CApi 16.0.8
[14:38:06] Needed hash was 682bb0caf9392f749f5ee785231d8ec0268a6ad2b8486994d767a9c5a7c5d3e4947ccbe32385517789abd7008e3d43d54d206c5f6dab3f6de5afd23067af5da1 actual hash was 682bb0caf9392f749f5ee785231d8ec0268a6ad2b8486994d767a9c5a7c5d3e4947ccbe32385517789abd7008e3d43d54d206c5f6dab3f6de5afd23067af5da1
[14:38:06] Validating NuGet package AltV.Net.Client 16.0.8
[14:38:06] Needed hash was 79b266cf20ad100778e08c300ad83e395bc407035ff9068bde9a4e4cc84a59f5e6930103e50a029f55275d6883e2e6e714249a849419fc5a8489e77e912dcd44 actual hash was 79b266cf20ad100778e08c300ad83e395bc407035ff9068bde9a4e4cc84a59f5e6930103e50a029f55275d6883e2e6e714249a849419fc5a8489e77e912dcd44
[14:38:06] Validating NuGet package AltV.Net.Shared 16.0.8
[14:38:06] Needed hash was 5a60dd646f08dddd18e1db4c53f87c125a25b59b6f99b83a25e714d296939345654bbe4b6d686b06bcf1f86cc64c6f31a0b490a8fcc8308d94b5ebc42e46ac13 actual hash was 5a60dd646f08dddd18e1db4c53f87c125a25b59b6f99b83a25e714d296939345654bbe4b6d686b06bcf1f86cc64c6f31a0b490a8fcc8308d94b5ebc42e46ac13
[14:38:06] Initializing CLR
[14:38:06] CLR initialized successfully
[14:38:06] Executing method from Host dll
[14:38:06] Host initialized. Sandboxing enabled: True
[14:38:06] Game config data setup
[14:38:08] All natives DLC packs preloaded
[14:38:29][Warning] System update WebApp took too much time to execute. 14 ms
[14:38:29][Warning] System update CTheScripts took too much. 11 ms
[14:38:29][Warning] System update SCRIPT took too much. 11 ms
[14:38:29][Warning] System update Audio took too much. 12 ms
[14:38:29][Warning] System update CTheScripts took too much. 113 ms
[14:38:29][Warning] System update SCRIPT took too much. 113 ms
[14:38:29] Loading FontRenderer
[14:38:29] CreateEnumeratorFromKey
[14:38:29] MoveNext 0 false
[14:38:29] Loaded FontRenderer
[14:38:29] Loaded font face 'rmlui-debugger-font' [regular] from 'memory'.
[14:38:29] Loaded font face 'rmlui-debugger-font' [italic] from 'memory'.
[14:38:29] Loaded font face 'rmlui-fallback-font' [regular] from 'memory'.
[14:38:29] Loaded font face 'rmlui-fallback-font' [italic] from 'memory'.
[14:38:31] Game Started in 1453398 ms
[14:38:31] Connecting to: [::ffff:127.0.0.1]:7788 MTU: 1392
[14:38:31][Warning] System update CTheScripts took too much. 2468 ms
[14:38:31][Warning] System update SCRIPT took too much. 2469 ms
[14:38:32] Connected with id: 1
[14:38:32] Loading resource muxt
[14:38:32] Starting resource
[14:38:32] Loading resource muxt
[14:38:32] Resolving AltV.Net.Client.Async
[14:38:32] Resolving AltV.Net.Client
[14:38:32] Trying to load from cache
[14:38:32] Resolving Shared
[14:38:32] Resolving AltV.Net.Shared
[14:38:32] Trying to load from cache
[14:38:32] Resolving AltV.Net.CApi
[14:38:32] Trying to load from cache
[14:38:32][Warning] Found mismatching SDK methods. Please update AltV.Net.Client NuGet.
[14:38:32] Core initialized
[14:38:32] Delegates set
[14:38:32] Main | Client side started

Server: No similiar log exists

I'll try again later and update here

Doxoh commented 4 months ago

pls test again, and reopen by issue here: https://github.com/FabianTerhorst/coreclr-module/issues