Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Bug Allocate Callback

Discussion in 'Game Server Hosting' started by tony040209_unity, Dec 13, 2022.

  1. tony040209_unity

    tony040209_unity

    Joined:
    Mar 21, 2021
    Posts:
    34
    Allocate Callback is a cold processing mechanism,
    I was testing the Allocate event yesterday and received it once,
    The next test did not receive the Allocate event.

    Then I looked at the FusionBr200 project,
    It is written in Start connecting to the game directly after SubscribeToServerEventsAsync
    And it says: "It's possible this is a cold start allocation",
    I laughed out loud on the spot.

    So here are some references for you, thank you.

    Code (CSharp):
    1.  
    2. // Setup allocations
    3. _multiplayEventCallbacks = new MultiplayEventCallbacks();
    4. _multiplayEventCallbacks.Allocate += OnAllocate;
    5. _multiplayEventCallbacks.Deallocate += OnDeallocate;
    6. _multiplayEventCallbacks.Error += OnError;
    7. _serverEvents = await MultiplayService.Instance.SubscribeToServerEventsAsync(_multiplayEventCallbacks);
    8.  
    9. // It's possible this is a cold start allocation (no event will fire)
    10. if (!string.IsNullOrEmpty(MultiplayService.Instance.ServerConfig.AllocationId))
    11. {
    12.     await StartGame();
    13. }
    14.  
     
    z0code0z likes this.
  2. danri

    danri

    Unity Technologies

    Joined:
    Jun 21, 2019
    Posts:
    27
    Hello,

    Could you provide some more details about the way in which you were testing the allocate event?

    1. Were you using test allocations or the Allocate API (https://services.docs.unity.com/multiplay-gameserver/v1#tag/Allocations) directly?
    2. After the first allocate event, did you stop or deallocate that server before trying to allocate it again?
     
  3. tony040209_unity

    tony040209_unity

    Joined:
    Mar 21, 2021
    Posts:
    34
    1.They are all in accordance with the formal, direct test function

    2.First Test allocations, manually shut down the server.
    Then start the formal matching process.
     
  4. z0code0z

    z0code0z

    Joined:
    Apr 10, 2018
    Posts:
    44
    I have come across the same issue but with just test allocations,

    1. Start test allocation, OnAllocate never fires (even though its been allocated)
    2. Deallocate manually (through the test allocation) - OnDeallocate fires off
    3. Start test allocation again, OnAllocate fires this time and everything proceeds as normal

    tested this in both start and awake methods, same result.
     
  5. z0code0z

    z0code0z

    Joined:
    Apr 10, 2018
    Posts:
    44
    Thank you for providing this! Was able to temporarily fix it on my end.
     
  6. VR-Innovations

    VR-Innovations

    Joined:
    Jul 17, 2017
    Posts:
    2
    from our Server logs it seems like the system does not get past the SubscribeToServerEventsAsync function.

    This happens randomly. After some allocations and deallocations.