Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Unity Multiplayer Mirror - Networking for Unity (UNET Replacement)

Discussion in 'Connected Games' started by vis2k, Aug 11, 2016.

  1. castana1962

    castana1962

    Joined:
    Apr 10, 2013
    Posts:
    391
    Hi Everyone. Sorry for my ignorance but I am new in this topic but I would need to do a multiplayer setup over the network to can make a test setup with Mobile and a PC version where I try to synchronize two players, for it, Could anybody say me how I can do it with Mirror?
    On the other hand and for that you can understand better what my main goal is.
    I am building Recovery Treatments for people with Motor and Cognitive problems through VR Video Games and I am thinking in adding to it the Asymmetric Virtual Reality function so that the patient plays in Virtual way (with the VR Headset) and their friends or family in a non-virtual way and through joysticks or cell phones interact with the patient into the same VR game with the aim of empowering and helping the patient achieve him/her goals.Hopefully you can understand me. Thanks for your time
     
    Last edited: May 31, 2020
  2. MonkeyS_Finger

    MonkeyS_Finger

    Joined:
    Nov 11, 2017
    Posts:
    7
    Hi, could you please tell me how can I implement [Command] atribute ignoring authority?
    I know that for security reasons this is not allowed, but I really need this for testing purpouses and this will be only for my personal use.

    I've found the code where you check the authority, but I just want to give [Command] a paramenter, or create a new [CommandNoAuth] for this specific task, i don't want to mess with the [Command] attribute code.
    can you please help me?
    I hope you could help me about this, I'm struggling to understand how the [Command] atribute works to make another one, but i'm going crazy.

    Thanks.
     
  3. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    317
    Vincent13122 likes this.
  4. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,683
  5. MarkoHazel

    MarkoHazel

    Joined:
    Apr 5, 2020
    Posts:
    15
    Hi,

    I have this code which I use in a card game to load images from a directory onto card prefabs and I want it to work with networking so each player can load in their own deck of cards with unique PNG images into the game:
    Code (CSharp):
    1. foreach (string gameobject in string list)
    2.             {
    3.  
    4.                 GameObject = Instantiate(spawnableprefab);
    5.                 byte[] bytes = File.ReadAllBytes(gameobject);
    6.             NetworkReaderPool.GetReader(bytes);
    7.             Texture2D texture = new Texture2D(1, 1);
    8.                 texture.LoadImage(bytes);
    9.                 gamobjectimage = GameObject.GetComponent<Image>();
    10.                 gamobjectimage.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
    11.         }
    Is there a method with Mirror that will allow each client to see the loaded PNGs from their end? Any examples would be greatly appreciated :)
     
  6. stanek_unity

    stanek_unity

    Joined:
    Jun 16, 2019
    Posts:
    10
    [Command(ignoreAuthority = true)]
     
    vis2k likes this.
  7. cpasjuste

    cpasjuste

    Joined:
    Apr 2, 2012
    Posts:
    145
    Hi,

    I'm a little (well a lot) lost with a server only mode (StartServer) and RpcClient calls.

    RpcClient calls are not called on server players, they are only called on (remote) clients/players. I wonder if it's a normal behavior? This seems to make things very complicated :/
    I think/tought client/players objects on the server should receive RpcClient calls, to easily maintain game/player states on the server.

    Please note that all is working fine in host mode (RpcClient calls are called on every clients, since one of the client is also the server).

    Could someone help me understand this ?

    Many thanks in advance,
    Cpasjuste.
     
  8. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    875
    Hey there! We have been getting a lot of requests from the Mirror community over the past few months to add support for Mirror to our Master Server Kit, so we decided to create a new asset named Dedicated Server Kit to provide player authentication and matchmaking functionality for Mirror-based games running on a dedicated server. You can find the official forum thread for the kit here.

    It is still early days, so please feel free to contribute to the aforementioned thread if you have any feedback on the initial release of the kit and/or any ideas on what would you like us to work on next.
     
    vis2k likes this.
  9. MonkeyS_Finger

    MonkeyS_Finger

    Joined:
    Nov 11, 2017
    Posts:
    7
    I've read abut that somewhere, but when I use that attribute there is the error "The name 'ignoreautority' does not exist in the current context"

    maybe there is something wrong i'm doing or something i'm missing?
    could be the version of mirror i'm using?
    accordingly to the versione file in the mirror folder i'm using the 9.0.2.

    could someone tell me what's wrong?
    thanks!
     
  10. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,683
    If you join our Discord then we can create a channel for your addon if you like :)

    Try latest Mirror master from github.
    We probably didn't update that change to asset store yet.
     
    gamevanilla likes this.
  11. ksc_3899

    ksc_3899

    Joined:
    Jan 1, 2019
    Posts:
    28
    How to handle RPC for late joiners?? I want them to receive the RPC calls as well.
     
  12. Jack-24

    Jack-24

    Joined:
    Oct 31, 2017
    Posts:
    1
    Beginner here:

    Is relay possible in Mirror? I am looking to achieve in Mirror something that is similar to what is shown here:


    Thanks!
     
    Last edited: Jul 25, 2020
  13. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,683
    Relay is possible. Check out our Discord, I think someone already made a relay addon a while ago.
     
  14. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,683
    Mirror V16.9.0 pending review!
    Several bug fixes and minor improvements.

    We have a lot of improvements planned for the near future with 1000 CCU in mind, so stay tuned and thanks for sponsoring :)
     
    Willbkool_FPCS likes this.
  15. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    85
    While it may be possible, Population One still hasn't launched although they have a working private beta, so yes it is possible. I think the real question that needs to be answered is how? Testing is hard as you cant run two games with build and Unity Play mode unless you some how have two HMD's set up on one desktop so instead its a slow Build move the build to another machine and connect a LAN to test. Then there is the way that Mirror plays with the SteamVR or Oculus frameworks. More tutorials on this are really needed. And any help finding relent information is greatly appreciated. I'm working on it in THIS thread but its slow going.
     
  16. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    85
    What version is this update in? I have 16.1.1 from the asset store, but git is up to 16.8.5?
     
  17. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,683
    Should be in 16.9.0 which is pending review right now. Probably out in 24 hours :)
     
    Giantbean likes this.
  18. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    85
    Cool with the update relating to VR is there any chance we may see VR examples for SteamVR, Oculus, and OpenXR soon?
     
  19. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,683
    Probably not because no one of us has a VR device and I don't even have a fast enough computer :)
     
  20. walter_j_r

    walter_j_r

    Joined:
    Mar 5, 2016
    Posts:
    12
    hello! Mirror can be used for a 1 Vs 1 game? like mortal kombat..
     
    XCO likes this.
  21. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    85
    Yes. One of the sample files is pong. Basically a 1 vs 1 network game at its simplest.
     
    walter_j_r likes this.
  22. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    85
    This sort of thing always makes me wish I could afford to buy other developers gear to help move the industry forward by having the tools placed in the right hands.

    Thanks anyways. Hopefully I will get something figured out over HERE and then maybe I or a more experienced dev could make a demo VR scene and submit a fork on git.
     
  23. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,683
    Don't worry about buying anyone gear :)
    It's more of a choice where working on a laptop provides freedom of movement, with the drawback of not being fast enough for VR.
     
    Giantbean likes this.
  24. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    85
    Hey there fine folks,

    I have been trying to connect two laptops with network discovery or the network HUD based on the mirror documentation and my clear lack of networking knowledge has me stumped. I have tried placing my IPv4 in the inspector as well as in the HUD field next to Client but as soon as I launch the host it says its Localhost 7777. Do I need to change the telepathy port? If I use network discovery I just get a no server found error. I have set up basic 192.168.0.x address on each laptop with a default ..0.1 gateway and 255...0 subnet mask, I have tested DHCP with each laptop connected to the modem to make sure the Ethernet cables are good (this sets the IP to obtain automatically and I have manually reset the properties although I am leaving the DNS blank. The set up I am trying to get working is with WiFi off and the laptops sharing connection over a netgear hub (no internet/modem in the mix). Network discovery, file and printer sharing have been turned on. Do I need to run a cable to the modem as well for this to work? I'm not using a crossover cable; its a switch with one laptop in port one and the other in port two. All my previous multiplayer testing was just with a build and the Unity Game window on one machine but now I need to test a LAN and nothing seems to work? Can anyone tell me what I am missing?

    P.S. If this should be asked somewhere else such as the discord or Unity answers let me know and I will remove it from this thread.
     
  25. zhn17

    zhn17

    Joined:
    Jul 30, 2019
    Posts:
    47
    Hello!

    I'm having an issue with Mirror, ever since I updated it from a 2018 version months ago to 2019 and now 2020, it doesn't seem to have any valid value for the player Network Identity's connectionToClient, the value is just plain null.

    I have tried creating a project, made a new scene and all of that in the latest 2020 official version, but it still doesn't work in any builds, only on the server.

    Here's the code, I would love if someone could send a fixed version of it as I'm basically out of finding possible solutions at this point:

    Code (CSharp):
    1. using Mirror;
    2. using UnityEngine;
    3.  
    4. public class PXPlayer : NetworkBehaviour
    5. {
    6.     public Animator animator;
    7.     public PXMMO mmo;
    8.  
    9.     private void Start()
    10.     {
    11.         mmo = GameObject.Find("Manager").GetComponent<PXMMO>();
    12.         if (!isLocalPlayer) return;
    13.         CmdPlay();
    14.         Debug.Log("STARTED");
    15.     }
    16.  
    17.     [Command]
    18.     public void CmdPlay()
    19.     {
    20.         var obj = Instantiate(mmo.spawnPrefabs[0]);
    21.         animator = obj.GetComponent<Animator>();
    22.         NetworkServer.Spawn(obj, gameObject);
    23.         RpcPlay();
    24.     }
    25.  
    26.     [ClientRpc]
    27.     public void RpcPlay() => animator.Play("CubeDummy");
    28. }
     
  26. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    85
    OK. Figured out the LAN. many hours watching videos and reading articles but not one mentioned the DNS settings. Set the preferred to all 1's and the alternate to all 2's and now the network discovery works fine for a offline LAN only connection with the Mirror network discovery and discovery HUD scripts. Mirror is fantastic!
     
  27. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    85
    Could you clarify what it means to work on the server only? For example can your Host see the transforms made by the client but he client can't see the movement of the host; Or something different?
     
  28. zhn17

    zhn17

    Joined:
    Jul 30, 2019
    Posts:
    47
    The server (Host & Play) can play animations just like normal and other's can see it, however when I spawn a client and join the localhost server, try to assign authority on a new object, it claims "Player is not a player.". I checked Mirror's code and this error occurs when a object's connectionToClient is null, which I can't find a solution for.
     
  29. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    85
    I think I am having this same issue in my 2019.4.3 build. When I launch the host they are visible to the client and their movement can be seen by the client but the host just gets a static spawned object of the clients player which doesn't move or interact with the world on the host screen.

    @vis2k is this a bug or something we are doing wrong?

    ... for me at least it was something I was doing wrong. I had to click client Authority on the NetworkTransformChild scripts.
     
    Last edited: Aug 10, 2020
  30. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    85
    Have parts of mirror like the experimental Network Rigidbody been removed from recent versions of mirror?

    P.S. I just imported the latest 16.9.0 from the asset store into a scene and its version file says its 16.1.1
     
    Last edited: Aug 7, 2020
  31. mickaelb_simthetiq

    mickaelb_simthetiq

    Joined:
    Nov 16, 2017
    Posts:
    6
    Hello!
    I am playing since yesterday with Mirror, and I wanted to know if there will be an easy way to store all communications from server to clients, in order to create a playback system? This should be really useful for deterministic playtesting and QC reviewing.

    Maybe all communications call a specific callback which I could hook in order to serialize the message and store it in a file. The second thing is to find also a way to replay all these messages at the right tick.

    Thanks.
     
  32. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,683
    It's possible, and not really Mirror related.
    Keep in mind that Unity PhysX is not stateless (it has state). So rewinding is difficult.
     
    akuno likes this.
  33. RakkuAmiya

    RakkuAmiya

    Joined:
    Jan 9, 2016
    Posts:
    24
    Is there a definitive guide to how to deal with multiple player prefabs?

    I've been having great success using Mirror to add multiplayer to my game, but when it comes to multiple starting characters I'm having trouble.

    The closest I had to success was, inefficiently, placing all three models (deactivated) inside the player prefab. On start, a SyncVar is used to identify the player type, the network animator is pointed to the appropriate models animator (all three models work differently), and then the model is activated followed by the NetworkAnimator component.

    That didn't work and throws up 'array out of bounds exceptions' from the NetworkAnimator.

    If I preassign the animator for one character type, then start the game with that type, it works great. However, if I change the animator I get 'array out of bounds exceptions' again.

    I'd originally designed the player types, actually three different birds, with their own NetworkAnimator and Identity components, and if I assign them as the player prefab they work spot on. No problems.

    To make the 'three bird' prefab, of course I had to move NetworkIdentity and Animator to the root object... If I create a basic object with a 'placeholder' animator, and just let it use that, it works but you only see the base animation on other clients even after changing the animator to the correct one for the bird. You don't see any animation on clients, presumably as it has set up based on the 'placeholder' animator.

    Anyway, multiple player prefabs... any definitive solution for Mirror? I'd tear my hair out, but I don't have much left!

    Graeme
     
  34. RealMTG

    RealMTG

    Joined:
    Jul 27, 2013
    Posts:
    357
    I thought I would just share my workflow with players as it may help you a bit.
    From the sound of it, you're spawning your player controller as the network player from the Network Manager. I would advise against that and use some kind of "Network Player" that is just an empty game object. On said Network Player you can then spawn different player prefabs with client authority (Something like NetworkServer.Spawn(myGameObject, myOwner) if I'm not mistaken). Just pass this.gameObject as myOwner.
    Then in your player scripts you would have to change all isLocalPlayer to hasAuthority instead.
    I hope this helps you! :)
     
  35. RakkuAmiya

    RakkuAmiya

    Joined:
    Jan 9, 2016
    Posts:
    24
    You complete legend... it took a while, but your idea worked. :) ... the annoying thing was getting the code in the right order to make sure the server spawned the player, as the client didn't have the authority to spawn of course. In the end, I added the instantiate and spawn code to the SendReady (Command on the server) bit and away it went.

    Thank you. :)

    Graeme
     
    RealMTG likes this.
  36. walter_j_r

    walter_j_r

    Joined:
    Mar 5, 2016
    Posts:
    12
    Hi! I'm working on a game 1vs1. I know I can run mirror in a game 1vs1, but I need to know if there is a way to set the server to work for example with 10 rooms automatically. Then at least 10 players will have a room to play. I have to run multiple instances of the game in the server with differents ports? Or there is a easy way to do this? Thanks!
     
  37. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    875
    That is right; you would need to build your own abstraction for the management of game rooms and matchmaking on top of Mirror. And every spawned game server instance (representing an independent game room) would use a different port number indeed.

    A bit of a shameless plug: if you are not interested in creating your own server backend, we recently released Dedicated Server Kit to help with this exact matter.
     
    walter_j_r likes this.
  38. RakkuAmiya

    RakkuAmiya

    Joined:
    Jan 9, 2016
    Posts:
    24
    Curious one this... by accident, in my game I clicked "Connect" to join a game at 'localhost' and it managed to join when nothing was hosting. It ended up in some sort of 'limbo' state where a player was created, then was destroyed.

    Previously I've been able to run two instances of the game on the same machine to test networking, and that's working great. I'd never tried to join a 'localhost' game without hosting. Is there a place I need to check? What is 'listening', if no one is serving?

    Very curious. I've not used any fancy code. I just call the StartClient method in the network manager, in the same way as the basic NetworkHud GUI example.

    Any ideas, or areas I should pin point?

    Thank you;

    Graeme
     
  39. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,683
    Can you try to reproduce it with our built in examples please? E.g. the tanks demo.
    If you press Connect, it calls StartClient.
    If you found a bug, please report it on the issue tracker (it's easier for us to reproduce if it happens in one of our built in demos)
     
  40. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,683
    mirror_icon_1200x630_NEW_SVG_BLACK.png
    Mission & Logo Update: https://github.com/vis2k/Mirror

    Hey guys. We refreshed our Logo and updated our Mission to better explain where we are going.

    We are using Mirror for our own projects, and we want them to survive the next decade or more. For that to happen, we need to keep the code as simple and stable as possible, while being very careful not to add anything that could break an MMO 10 years from now.

    We are developing Mirror based on a 1st principles approach, considering problems from the ground up.

    At the moment, our biggest goal is get the transports right, from the ground up, so we never have to worry about them again.

    libuv
    Libuv will soon replace Telepathy & Apathy as the TCP library of choice. It's extremely high scale, extremely stable, battle tested billions of times by Node.js. Libuv will receive free updates by some of the best networking engineers in the world, for years to come.

    Websockets
    Websockets have never been on par with our other transports, which is why @JamesFrowen is reimplementing them from scratch. We will not rely on Mono's broken async-await anymore, and James will make it fit exactly to our needs.

    After we come back from the deep depths of Transports, we will work towards the anticipated 1000 CCU community test, most likely using uMMORPG again.

    Thanks to all the supporters :)
     
    Yavvn, Willbkool_FPCS and zyzyx like this.
  41. RakkuAmiya

    RakkuAmiya

    Joined:
    Jan 9, 2016
    Posts:
    24
    I'd considered that, but then found that the Steam version did not have the fault suggesting that it was an error on my part.

    And sure enough, the bug was my doing. All fixed now, and definitely no fault found in Mirror by me. :)

    Graeme
     
    vis2k likes this.
  42. super-cypher

    super-cypher

    Joined:
    May 10, 2014
    Posts:
    116
    hi
    quick question. I use playmaker to build my games, how easy/hard would it be to use mirror with playmaker? i plan on making a 'battle royale' game along the lines of fortnite/PUBG/warzone etc with 100 -150 players per game (room) and as i understand it mirror is the only option for this in unity.

    if playmaker support is not currently available are there any plans to add it anytime soon?

    thanks
     
  43. patrickk2

    patrickk2

    Joined:
    Dec 8, 2019
    Posts:
    26
    Hello everybody!

    I am having a bit of trouble when using Websockets, and I am not sure, if I am doing something wrong. I was hoping you guys could point me in the right direction.

    I am trying to get the Chat example working with Websocket. I only replaced the Transport component with the Websocket one, and changed nothing else. Then I build a windows server and a WebGL client. When I load the client in two different browsers (so I can test the chat), most of the time the second browser to connect will throw this error, whenever I try to send a message (connecting seems to be working):

    NullReferenceException: Object reference not set to an instance of an object.

    (Filename: currently not available on il2cpp Line: -1)

    _JS_Log_Dump @ webgl.framework.js:3299
    __Z19WebGLPrintfConsolev7LogTypePKcPi @ webgl.wasm:0x1e0cca
    __ZL20InternalErrorConsolePKcz @ webgl.wasm:0x1e0b49
    __Z40DebugStringToFilePostprocessedStacktraceRK21DebugStringToFileData @ webgl.wasm:0x1e06d5
    __Z17DebugStringToFileRK21DebugStringToFileData @ webgl.wasm:0x1dec5f
    __ZN9Scripting23LogExceptionFromManagedE21ScriptingExceptionPtriPKcb @ webgl.wasm:0x1f61b8
    __Z44DebugLogHandler_CUSTOM_Internal_LogExceptionP12Il2CppObjectS0_ @ webgl.wasm:0x5c90c5
    _DebugLogHandler_Internal_LogException_mD0D1F120433EB1009D23E64F3A221FA234718BFF @ webgl.wasm:0xc409d8
    _DebugLogHandler_LogException_m131BB407038398CCADB197F19BB4AA2435627386 @ webgl.wasm:0xc40a25
    __ZN23InterfaceActionInvoker2IP12Il2CppObjectS1_E6InvokeEtP11Il2CppClassS1_S1_S1_ @ webgl.wasm:0xa71bd7
    _Logger_LogException_m207DC0A45A598148B848CF37BE3A20E6C3BB10F1 @ webgl.wasm:0xc45003
    __ZN23InterfaceActionInvoker2IP12Il2CppObjectS1_E6InvokeEtP11Il2CppClassS1_S1_S1_ @ webgl.wasm:0xa71bd7
    _Debug_LogException_m1BE957624F4DD291B1B4265D4A55A34EFAA8D7BA @ webgl.wasm:0xc3a144
    _ExecuteEvents_Execute_TisRuntimeObject_m20F4B1FD39A6BA916CF0A469A0D71DE4DC727B26_gshared @ webgl.wasm:0xb5fe4b
    __Z125ExecuteEvents_Execute_TisIDeselectHandler_tC65437D29B1CF4E31F026448AF2CADC21FADCD33_mC975A3757BAB1DC8A130702B3531C4E9CCCC9D6CP52GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319P55BaseEventData_t722C48843CF21B50E06CC0E2E679415E38A7444EP57EventFunction_1_tC96EF7224041A1435F414F0A974F5E415FFCC528PK10MethodInfo @ webgl.wasm:0xba0051
    _StandaloneInputModule_ReleaseMouse_mEE3FAAA8B87CAE09F156322B7A38E2EC5460E1BB @ webgl.wasm:0xe7a89c
    _StandaloneInputModule_ProcessMousePress_mE5D5A47900D7FAFCBBC58ACBDCB03BE2958FF7A6 @ webgl.wasm:0xe7bdcd
    _StandaloneInputModule_ProcessMouseEvent_m1D697D9E5F2FDF5B770471185CD364D12A89B18A @ webgl.wasm:0xe7b793
    _StandaloneInputModule_ProcessMouseEvent_m0E5CCCC3F32DF86C32E02873DDE2BF29E9A05E37 @ webgl.wasm:0xe7b0de
    _StandaloneInputModule_Process_mEA8D89C754B958916467AEB75592670B15519D98 @ webgl.wasm:0xe7adf8
    __ZN18VirtActionInvoker06InvokeEtP12Il2CppObject @ webgl.wasm:0xa42abf
    _EventSystem_Update_mF0C1580BB2C9A125C27282F471DB4DE6B772DE6D @ webgl.wasm:0xbad661
    __Z65RuntimeInvoker_TrueVoid_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5PFvvEPK10MethodInfoPvPS4_ @ webgl.wasm:0xa0db43
    dynCall_iiiii @ webgl.wasm:0xfaa766
    (anonymous) @ webgl.framework.js:25709
    invoke_iiiii @ webgl.framework.js:16787
    __ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP15Il2CppException @ webgl.wasm:0xf2bdc6
    _il2cpp_runtime_invoke @ webgl.wasm:0xf098da
    __Z23scripting_method_invoke18ScriptingMethodPtr18ScriptingObjectPtrR18ScriptingArgumentsP21ScriptingExceptionPtrb @ webgl.wasm:0x1f5da7
    __ZN19ScriptingInvocation6InvokeEP21ScriptingExceptionPtrb @ webgl.wasm:0x1f5b6a
    requestAnimationFrame (async)
    requestAnimationFrame @ webgl.framework.js:9801
    Browser_mainLoop_scheduler_rAF @ webgl.framework.js:9358
    Browser_mainLoop_runner
    ...
    (The last four lines repeat a couple of times.)

    I am not sure if this is connected but directly after connecting with the client that throws this error, I see this warning in the console:

    Did not find target for sync message for 4 . Note: this can be completely normal because UDP messages may arrive out of order, so this message might have arrived after a Destroy message.
    (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

    _JS_Log_Dump @ webgl.framework.js:3302
    __Z19WebGLPrintfConsolev7LogTypePKcPi @ webgl.wasm:0x1e0cca
    __ZL22InternalWarningConsolePKcz @ webgl.wasm:0x1e0c1b
    __Z40DebugStringToFilePostprocessedStacktraceRK21DebugStringToFileData @ webgl.wasm:0x1e06d5
    __Z17DebugStringToFileRK21DebugStringToFileData @ webgl.wasm:0x1def2a
    __Z35DebugLogHandler_CUSTOM_Internal_Log7LogType9LogOptionP12Il2CppStringP12Il2CppObject @ webgl.wasm:0x5c9000
    _DebugLogHandler_Internal_Log_mA1D09B6E813ABFAB6358863B6C2D28E3ACA9E101 @ webgl.wasm:0xc409a2
    _DebugLogHandler_LogFormat_mB876FBE8959FC3D9E9950527A82936F779F7A00C @ webgl.wasm:0xc409f0
    __ZN23InterfaceActionInvoker4IPvP57unitytls_tlsctx_tA5DB674E2A83ADDD03624096501FCDD29E9DB7FAPhlE6InvokeEtP11Il2CppClassP12Il2CppObjectS0_S2_S3_l @ webgl.wasm:0xaeb3c7
    _Logger_LogFormat_m7D6FBEBB9C9708A50311878D7AF5A96E6E9A11F4 @ webgl.wasm:0xc44fb8
    __ZN23InterfaceActionInvoker4IPvP57unitytls_tlsctx_tA5DB674E2A83ADDD03624096501FCDD29E9DB7FAPhlE6InvokeEtP11Il2CppClassP12Il2CppObjectS0_S2_S3_l @ webgl.wasm:0xaeb3c7
    _Logger_Log_mBAF75BD87C8B66198F52DEFF72132C42CA369881 @ webgl.wasm:0xc44d37
    __ZN23InterfaceActionInvoker2IP12Il2CppObjectS1_E6InvokeEtP11Il2CppClassS1_S1_S1_ @ webgl.wasm:0xa71bd7
    _ILoggerExtensions_LogWarning_m3FD75476864865C9D84D6063DA665C67EA1DF2C5 @ webgl.wasm:0xaefdf7
    _ClientScene_OnUpdateVarsMessage_m3F82D211A684829F97585F4A682123B571BD7EB2 @ webgl.wasm:0xaf9b22
    _Action_1_Invoke_mB8046BAA1B2EFC06B1E135F44801C1F963842C2E_gshared @ webgl.wasm:0xd285a9
    _U3CU3Ec__DisplayClass31_0_1_U3CRegisterHandlerU3Eb__0_m2585F1ED76B67EDB75895D88EBE5ED9E1260BF6E_gshared @ webgl.wasm:0xd1b407
    _Action_2_Invoke_m404CD85F794F2CE1A4A1F0B342EDAF8603BB9A30_gshared @ webgl.wasm:0xd2d7a8
    _U3CU3Ec__DisplayClass7_0_2_U3CMessageHandlerU3Eb__0_m309D0A48F45D0E9B64B500FDA9E318A15CD11D0F_gshared @ webgl.wasm:0xd23067
    _CmdDelegate_Invoke_m8DA7D950737AA88947D43EBAED1C35604D49DC2B @ webgl.wasm:0xafad24
    _NetworkConnection_InvokeHandler_mAC8422AD59782431ACDBD2CF282D1E05404D43EC @ webgl.wasm:0xb0350c
    dynCall_iiiiii @ webgl.wasm:0xfaa7e5
    (anonymous) @ webgl.framework.js:25729
    invoke_iiiiii @ webgl.framework.js:16827
    _NetworkConnection_TransportReceive_m473F63A4BCD1C0C9E7AE6C68CD070AB2BB25F049 @ webgl.wasm:0xb032f4
    _NetworkClient_OnDataReceived_m6DC574679B247729F8E6E0740D488AA68FF6E1BB @ webgl.wasm:0xb02d83
    _UnityAction_2_Invoke_m9D0CA4E53EF63147E8BB5C57BC5B9A0DB7584243_gshared @ webgl.wasm:0xd9ed92
    _InvokableCall_2_Invoke_mF26A51709DBAB4194EC8C6FB21F7F2EC07BAA2DE_gshared @ webgl.wasm:0xc56ec5
    _UnityEvent_2_Invoke_m9148ACDC58C59488BE7FF86A4F5F5D5F7DC2452C_gshared @ webgl.wasm:0xda1134
    __Z61UnityEvent_2_Invoke_m9148ACDC58C59488BE7FF86A4F5F5D5F7DC2452CP54UnityEvent_2_t465E6179EC05C086533A58914515AC6EFEF790C556ArraySegment_1_t89782CFC3178DB9FD8FFCCC398B4575AE8D740AEiPK10MethodInfo @ webgl.wasm:0xafc5dd
    requestAnimationFrame (async)
    requestAnimationFrame @ webgl.framework.js:9801
    Browser_mainLoop_scheduler_rAF @ webgl.framework.js:9358
    Browser_mainLoop_runner
    ...
    (The last four lines repeat a couple of times.)

    I would really appreciate any hints and tipps about this problem. Since this is really just the Chat example with only the transport component replaced, I don't really know what I am doing wrong here.

    Thanks in advance for your thoughts on this issue and best regards,
    Patrick
     
  44. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    113
    I can't seem to find any mention of snapshots or related subjects in the documentation. Anyone able to link me to related docs or give me a brief summary on how Mirror handles syncing of data across multiple objects to clients? Is the data for all game objects sent at once for each tick or is it sent individually per object?

    I'm still using Unet/HLAPI and had issues originally with data being synced individually. This resulted in clients having data for object one at tick 10, but object two only had data from tick 9 or 8 etc. From what I understood data was being sent individually and not all at once, so there was no guarantee they arrive at the same time.

    This caused problems with lag compensation and knowing how far to back to rewind as the client was seeing different versions for each object. I had to manually add "snapshots" to get all data from all objects and send it all at once. That way if the client had "snapshot" at tick 10, they had that data for all objects, not just some.

    I'm wondering if I'm still responsible for implementing this with Mirror or is there any built in solutions?
     
  45. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,683
    Showcase: check out Zooba - the 5th largest Battle Royale Shooter in the US mobile market!

    Made with 2020-10-06_20-36-09.png by https://wildlifestudios.com/, one of the 10 largest mobile gaming companies in the world.

    Everything is possible.
    No excuses.
     
    akuno likes this.
  46. HajiyevEl

    HajiyevEl

    Joined:
    Feb 19, 2020
    Posts:
    29
    Hi vis2k! Can you please tell me, if i have SyncDictionary, and inside this SyncDictionary i have another Dictionary(not Sync), will client get updates when nested dictionarys values change? Also what about Lists(not sync) inside SyncDictionary? And also what about List of structs (not sync) inside SyncDictionary? What collections will sync properly inside SyncDictionary?
     
  47. ConjureScape

    ConjureScape

    Joined:
    Feb 14, 2013
    Posts:
    439
    Our client has done a penetration test on our application which uses mirror networking.
    The code has been flagged with "Insecure Randomness" as seen in the screenshot.
    upload_2020-10-12_10-18-44.png
     
  48. ConjureScape

    ConjureScape

    Joined:
    Feb 14, 2013
    Posts:
    439
    Explanation

    Insecure randomness errors occur when a function that can produce predictable values is used as a source
    of randomness in a security-sensitive context. Computers are deterministic machines, and as such are
    unable to produce true randomness. Pseudorandom Number Generators (PRNGs) approximate
    randomness algorithmically, starting with a seed from which subsequent values are calculated. There are
    two types of PRNGs: statistical and cryptographic. Statistical PRNGs provide useful statistical properties,
    but their output is highly predictable and form an easy to reproduce numeric stream that is unsuitable for
    use in cases where security depends on generated values being unpredictable. Cryptographic PRNGs
    address this problem by generating output that is more difficult to predict. For a value to be
    cryptographically secure, it must be impossible or highly improbable for an attacker to distinguish between
    the generated random value and a truly random value. In general, if a PRNG algorithm is not advertised as
    being cryptographically secure, then it is probably a statistical PRNG and should not be used in securitysensitive
    contexts, where its use can lead to serious vulnerabilities such as easy-to-guess temporary
    passwords, predictable cryptographic keys, session hijacking, and DNS spoofing. Example: The following
    code uses a statistical PRNG to create a URL for a receipt that remains active for some period of time after
    a purchase.

    string GenerateReceiptURL(string baseUrl) {
    Random Gen = new Random();
    return (baseUrl + Gen.Next().toString() + ".html");
    }

    This code uses the Random.Next() function to generate "unique" identifiers for the receipt pages it
    generates. Since Random.Next() is a statistical PRNG, it is easy for an attacker to guess the strings it
    generates. Although the underlying design of the receipt system is also faulty, it would be more secure if it
    used a random number generator that did not produce predictable receipt identifiers, such as a
    cryptographic PRNG.
     
  49. Vincenzo

    Vincenzo

    Joined:
    Feb 29, 2012
    Posts:
    136
    If you have any security requirements. Don't use mirror or any other such free plugin. They are not secure in the first place. Way worse than a rng for websockets.
    Set up your own encryption. Good luck.
     
  50. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,683
    Thanks for letting us know.
    Our websocket transport uses Ninja.Websockets. It was nice to have an existing solution when we started, but Ninja doesn't work that well, and it's very slow.

    If you don't need to run WebGL then simply delete the Transport.
    If you do need WebGL, join our Discord and check the websockets channel. James is currently working on a new one, you can already try it out.

    I know that he uses RngCryptoServiceProvider in that place, which gives us cryptographic random numbers.

    Mirror is fully server authoritative to protect against cheaters. That being said, we stay away from encryption because no one in our team is a crypto expert. If you want encryption, it's best if you add it yourself to Mirror or to the transport.

    Websockets is the only exception where we will have to add encryption, so that it runs on https websites. Still, use it at your own risk.
     
unityunity