Search Unity

DarkRift Networking 2

Discussion in 'Assets and Asset Store' started by Jamster, Feb 7, 2018.

  1. Deleted User

    Deleted User

    Guest

    Is it possible to assign a value to the onConnected() parameter "object sender" from the client
     
  2. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    It is not I'm afraid, the 'sender' parameter is a .NET standard practice and always contains the object that triggered the event. You can always send a message once the client has connected containing whatever you need!
     
  3. knxrb

    knxrb

    Joined:
    Dec 16, 2018
    Posts:
    21
    Hello,

    Are the Inter-server Communication and Area of Interest System (Helper) features available in Pro yet? On the website they say coming in 2019 and 2020 respectively, but I don't see them as confirmed anywhere on the store page or documentation.
     
  4. chrisx84

    chrisx84

    Joined:
    Nov 9, 2011
    Posts:
    85
    hey sorry for the long delay in reply, by default VS 2017 wants to debug the client, switching to Server.Console works for a successful build. Thanks Jamster now i can get back to making a MMO.
    Still got the same .NET 2.1 error when trying to compile, debugging right in VS works just fine.
     
    Last edited: Jul 22, 2020
  5. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DarkRift 2.7.0 is now available on the website!
    This release primarily adds the new metrics system for pro users: You can now integrate your DarkRift clusters with your OPs centres and monitoring systems, take advantage of Kubernetes horizontal auto scalers and visualiser your servers using Prometheus (built in) or any other metrics system.

    We've curated a dashboard in Grafana to get you started!
    https://github.com/DarkRiftNetworking/grafana-dashboards

    This release also contains a number of bug fixes and performance improvements!

    The update is already available on the website here, or through the DarkRift CLI tool!
    https://www.darkriftnetworking.com/DarkRift2/Releases/Free/2.7.0.unitypackage
    https://www.darkriftnetworking.com/DarkRift2/Releases/Pro/2.7.0.unitypackage?invoice=<your invoice number>

     
    Last edited: Aug 12, 2020
    knxrb likes this.
  6. knxrb

    knxrb

    Joined:
    Dec 16, 2018
    Posts:
    21
    The clickable URLs for the downloads are pointing to the v2.6.0 version of the package. Here's fixed links for those wanting them:

    Free: https://www.darkriftnetworking.com/DarkRift2/Releases/Free/2.7.0.unitypackage
    Pro: https://www.darkriftnetworking.com/DarkRift2/Releases/Pro/2.7.0.unitypackage?invoice=<your invoice number>
     
  7. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Whoops! Thanks for that, fixed!
     
  8. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DarkRift 2.7.0 is now available on the Asset Store!
     
    LostPanda likes this.
  9. zeiksz

    zeiksz

    Joined:
    Mar 10, 2019
    Posts:
    10
    Hi!

    My usecase is "server maintenance", that client is on autoconnect and server is down. Client is starting up and of course autoconnects. It can not, because there is no server. But later on I will start the server too. Client is unable to connect AND stays in "connecting" state.

    If I want to manually ".Connect(...)" the client .NET socketexception is thrown.

    Is there a way to make client retry connecting or just forget it's connecting state or get a proper timeout or... something?

    Thank you for your help:
    Péter
     
  10. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Hi Péter!

    Does the issue you're seeing look like this bug?

    I don't really know a good workaround for the moment, if you can catch the exception and recreate the UnityClient that might be the best bet until it's fixed.

    Jamie
     
  11. zeiksz

    zeiksz

    Joined:
    Mar 10, 2019
    Posts:
    10
    Hi Jamie!

    Thank you for the support!
    Yes and the exception message is the same as well.

    Workaround I tried and failed so far: disabling and enabling the component (does nothing, because the UnityClient is created in the Awake), repeating the Start method (leads to the Exception), disabling the whole object and enabling it only after the server is awake (works, but kills purpose of detecting maintenance), maybe some others but forgot them.

    What I will try then: re-creating the whole component on GameObject.

    Thanks:
    Péter
     
  12. zeiksz

    zeiksz

    Joined:
    Mar 10, 2019
    Posts:
    10
    This will do the trick as "workaround" for previous:

    Code (CSharp):
    1.    
    2. //[SerializeField]  UnityClient kliens;
    3. //...
    4.  
    5. if (kliens.ConnectionState != ConnectionState.Connected)
    6.     {
    7.       IPAddress ip = kliens.Address;
    8.       ushort port = kliens.Port;
    9.       Destroy(kliens.gameObject.GetComponent<UnityClient>());
    10.       kliens = kliens.gameObject.AddComponent<UnityClient>();
    11.       kliens.Address = ip;
    12.       kliens.Port = port;
    13.     }
    Of course it is not a full solution, it copies only the IP and the port.
    Péter
     
  13. super-cypher

    super-cypher

    Joined:
    May 10, 2014
    Posts:
    117
    hi
    quick question. I use playmaker to build my games, how easy/hard would it be to use darkrift 2 with playmaker? i plan on making a 'battle royale' game along the lines of fortnite/PUBG/warzone etc with 100 players per game (room).

    thanks
     
  14. manutoo

    manutoo

    Joined:
    Jul 13, 2010
    Posts:
    524
  15. hugopok

    hugopok

    Joined:
    Mar 30, 2016
    Posts:
    46
    Hi this library can be deployed on ps4 and nintendo switch ?
     
  16. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Apologies for the late reply to everyone, I haven't been receiving notifications for some reason!

    I'm afraid I haven't used Playmaker before so I can't really comment. DR is very programmatic so if it Playmaker allows you to make arbitrary C# calls then I suspect it will work, though I don't know how easy that will be!

    I know some people in the community build for consoles but I don't know which consoles they are nor how easy they are to build for. DarkRift isn't tested on consoles so I won't make any claims for it to work on them! The best advice I can suggest is to just try it with the free version!
     
  17. silchuks969

    silchuks969

    Joined:
    Sep 18, 2020
    Posts:
    2
    DarkRift 2.7.0 unity server outputs this error " HttpListenerException: Listener closed" when shutdown. any fix?
     
  18. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    I think this is a bug that will be fixed in the next version. If you're not using the HTTP health check or the Prometheus metrics (pro) you could disable the associated plugins (HttpHealthcheck/PrometheusEndpoint) to stop the errors ocurring.
     
  19. tungqlvip

    tungqlvip

    Joined:
    May 7, 2018
    Posts:
    6
    I have an error.Occasionally, the client will not receive a response from the server. but that client still sends the message and the server still receives them.
     
  20. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Strange. The only way I can imagine that ocurring is if the update loop in UnityClient has stopped. Have you modified any of the DarkRift files? Are there any disconnection logs output either end?
     
  21. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DarkRift 2.8.0 is now available on the website!
    DarkRift 2.8.0 being the beta of server clustering (formerly referred to as inter-server communication) as well as a few bug fixes!

    Check out the docs to get started with the server clustering beta here!
    https://www.darkriftnetworking.com/DarkRift2/Docs/2.8.0/advanced/clustering/index.html

    The update is already available on the website here, or through the DarkRift CLI tool and will be available on the asset store in the coming few days!
    https://www.darkriftnetworking.com/DarkRift2/Releases/Free/2.8.0.unitypackage
    https://www.darkriftnetworking.com/DarkRift2/Releases/Pro/2.8.0.unitypackage?invoice=<your invoice number>
     
    unlikelysurvival and knxrb like this.
  22. BitPax

    BitPax

    Joined:
    Oct 4, 2019
    Posts:
    89
    If I authenticate the user via php and then I connect them to the Dark Rift server how would php pass the userID to Dark Rift so I can access the database based on their ID through Dark Rift?

    Obviously I shouldn't let the client pass the userID to the server since that would be a security risk. It should all be done on the server side. Is there a recommended way for php to send a variable to Dark Rift?

    Which part of the documentation should I be looking at?
     
  23. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DarkRift 2.8.0 is now available on the Asset Store!
     
  24. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Usually the best way is to return the user a token of some form, such as a JWT (JSON Web Token) or some randomly generated short-lived token. That token can then be handed to the DarkRift serverto prove the client is who they say they are.

    JWTs are signed to be from your server so the client can't modify them in a way accepted by the server, short lived tokens are just randomly generated so can't be spoofed! There are plenty of other ways to do it as well, personally though I'd lookat a JWT I think as I've used them before!
     
    BitPax likes this.
  25. BitPax

    BitPax

    Joined:
    Oct 4, 2019
    Posts:
    89
    Is there a way for php to just send the variable data directly to Dark Rift?

    EDIT: Actually I think I understand. I'll go try it out and report back later. Thank you!
     
    Last edited: Nov 4, 2020
    Jamster likes this.
  26. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DarkRift 2.8.1 is now available on the website!

    This manly fixes a bug where the pro server wouldn't start unless you were using server clustering!

    The update is already available on the website here, or through the DarkRift CLI tool and will be available on the asset store in the coming few days!
    https://www.darkriftnetworking.com/DarkRift2/Releases/Free/2.8.1.unitypackage
    https://www.darkriftnetworking.com/DarkRift2/Releases/Pro/2.8.1.unitypackage?invoice=<your invoice number>

     
    knxrb likes this.
  27. xpxilom

    xpxilom

    Joined:
    Aug 28, 2014
    Posts:
    30
    Soy nuevo, donde puedo encontrar tutoriales de DR2?
     
  28. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Hola, hay un tutorial de DR2 aquí y un tutorial de comunidad aquí, pero ambos estan en inglés.

    No sé de un tutorial en Espanol, lo siento!
     
    xpxilom likes this.
  29. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
  30. NOT_A_ROBOT1101

    NOT_A_ROBOT1101

    Joined:
    Jun 18, 2020
    Posts:
    39
    Hello,
    When trying to implement your asset in my program, this error occured:

    Code (CSharp):
    1. DarkRiftConnectionException: Unable to establish TCP connection to remote server.
    2. DarkRift.Client.BichannelClientConnection.Connect () (at <3a26bbcd2cce497ebf128d6d1cf80437>:0)
    3. DarkRift.Client.DarkRiftClient.Connect (DarkRift.Client.NetworkClientConnection connection) (at  <3a26bbcd2cce497ebf128d6d1cf80437>:0)
    4. DarkRift.Client.DarkRiftClient.Connect (System.Net.IPAddress ip, System.Int32 port, System.Boolean noDelay) (at <3a26bbcd2cce497ebf128d6d1cf80437>:0)
    5. DarkRift.Client.Unity.UnityClient.Connect (System.Net.IPAddress ip, System.Int32 port, System.Boolean noDelay) (at Assets/DarkRift/DarkRift/Plugins/Client/UnityClient.cs:254)
    6. DarkRift.Client.Unity.UnityClient.Start () (at Assets/DarkRift/DarkRift/Plugins/Client/UnityClient.cs:208)
    7.  
    Could you please help me?
    Server code:
    Code (CSharp):
    1. public XmlUnityServer server;
    2. public Data dataClass;
    3.     public void Update()
    4.     {
    5.         // Gets all clients
    6.         IClient[] clients = server.Server.ClientManager.GetAllClients();
    7.         for (int i = 0; i < clients.Length; i++)
    8.         {
    9.             // Gets message/packet from Data class and sends them to all clients
    10.             clients[i].SendMessage(dataClass.Get(), mode);
    11.         }
    12.     }
    Client code:
    Code (CSharp):
    1. public UnityClient client;
    2.     public void Awake()
    3.     {
    4.         // User inputs IP, code checks if IP is valid, then IP gets saved to PlayerPrefs. Then, load client scene.
    5.         client.Address = System.Net.IPAddress.Parse(UnityEngine.PlayerPrefs.GetString("IP"));
    6.         UnityEngine.PlayerPrefs.DeleteAll();
    7.     }
    8.  
    Thanks in advance!
     
  31. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Sure can!

    Where are you hosting your server and what type of IP address are you trying to connect with (Public? LAN? Localhost?)

    If the server is just hosted on a player's machine they will need to port forward the TCP and UDP port on their router.
     
  32. NOT_A_ROBOT1101

    NOT_A_ROBOT1101

    Joined:
    Jun 18, 2020
    Posts:
    39
    I want the client to communicate with a local server on the same network (LAN) and the user can manually type the server IP. This is currently not working.

    Also, when I added a Debug.Log() function on the Start() function of one of your scripts (i forgot which), it does not log anything on the console, even though it was the first function in Start(). I am sure I put the script on an active GameObject.
     
  33. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    OK, in that case you want to be using the internal IP address (i.e. the one found from on ipconfig) rather than the public IP
    (e.g. the one external websites tell you). Are you using that?
     
  34. NOT_A_ROBOT1101

    NOT_A_ROBOT1101

    Joined:
    Jun 18, 2020
    Posts:
    39
    Yes. I have been using it. I have a script on the server to set a Text GameObject to show the local IP.
    (By the way, the server and the client uses the same Unity project, but different scenes. If this setup does not work, let me know :))

    Also, does DarkRift Networking 2 support multiplatform (Android = server, PC = client)? Thanks in advance!
     
  35. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DarkRift 2.9.0 is now available on the website!

    This mainly contains bug fixes and quality of life improvements for server clustering but also contains a few new features. You can now use a DNS name in the UnityClient component and can use environment variables in configuration!

    The update is already available on the website here, or through the DarkRift CLI tool and will be available on the asset store in the coming few days!
    https://www.darkriftnetworking.com/DarkRift2/Releases/Free/2.9.0.unitypackage
    https://www.darkriftnetworking.com/....0.unitypackage?invoice=<your invoice number>

     
    Last edited: Dec 6, 2020
    knxrb likes this.
  36. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Building the server and clinet from the same project is fine, but you should be aware you can end up with server only stuff in your client builds and vice versa, you usually want to have some conditional compilation etc. to separate them!

    DR2 is multiplatform client wise yes, but the server is only designed to run on a PC/server, running servers on android comes with a whole host of issues even if DR does techncically run on it.
     
  37. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DarkRift 2.9.0 is now available on the Asset Store!
     
  38. Rickmc3280

    Rickmc3280

    Joined:
    Jun 28, 2014
    Posts:
    189
    Looking at this on the Asset store, but had a few questions.

    Is this basically a solution to build our own servers without having to use other "Services" and buy the ccus? Most of the ones I have found are just "wrappers" of "templates" if you will for Pun, etc etc. Looking for a simple, no service provider needed solution. I dont plan on using this for gaming over the web as much as I do over LAN networks.

    Ive made basic servers for handling very simple data, hoping this is similar except very well formed and easy to implement?
     
    Last edited: Dec 17, 2020
  39. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Hi!

    Yes, DarkRift is a standalone application that you host (usually on a VPS but over LAN is also fine) rather than a service such as those Photon provide. It also has no CCU limits on it, once you download it you can connect as many people to as many servers as you like with it.

    DarkRift is a low level solution so it's quite different to use compared to Photon and others, I always recommend just downloading the free version and having a play - that's the best way to know if it's for you!

    Jamie
     
  40. silchuks969

    silchuks969

    Joined:
    Sep 18, 2020
    Posts:
    2
    Can you send unordered udp messages?
     
  41. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Yes, use DarkRift's 'unreliable' send mode :)
     
  42. Kakusin

    Kakusin

    Joined:
    Feb 1, 2017
    Posts:
    3
    I am trying to send a message to a Darkrift server with a Python WebSocket client. However, I am getting an error on the server side. Is there any way to send the message correctly from Python?

    The error message is as follows
    Code (CSharp):
    1. [Info]    ClientManager         New client [0] connected [150.249.XXX.XXX:61314].
    2. 2020/12/28 15:50:25|Error|<>c__DisplayClass71_0.<receiveRequest>b__0:0|Operation is not supported on this platform.
    3. [Info]    ClientManager         Client [0] disconnected.
     
  43. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DarkRift doesn't support Python clients so I presume you're writing your own here with the source as reference?

    And I'm guessing you're using one of the websocket listeners available on GitHub? This looks more like an exception from inside the websocket listener so it might be better to reach out to the author of the library your using for help. I'm not sure that exception is because your connecting via Python, but more that the platform your server is running on isn't supported by the listener you're using.
     
  44. Roleks

    Roleks

    Joined:
    Jan 22, 2014
    Posts:
    3
    I'm using Dark RIft 2.9.0, when having other clients we all seem to disconnect with the error "Success"
    Disconnected from server, error: Success
    I don't use Disconnect in any areas of my code, what could be possibly going wrong?

    Code (CSharp):
    1. Disconnected from server, error: Success
    2. UnityEngine.Debug:Log(Object)
    3. DarkRift.Client.Unity.UnityClient:Client_Disconnected(Object, DisconnectedEventArgs) (at Assets/DarkRift/DarkRift/Plugins/Client/UnityClient.cs:524)
    4. DarkRift.Client.DarkRiftClient:DisconnectedHandler(SocketError, Exception)
    5. DarkRift.Client.NetworkClientConnection:HandleDisconnection(SocketError)
    6. DarkRift.Client.BichannelClientConnection:Disconnect(SocketError)
    7. DarkRift.Client.BichannelClientConnection:HandleDisconnectionDuringHeaderReceive(SocketAsyncEventArgs)
    8. DarkRift.Client.BichannelClientConnection:ReceiveHeaderAndBody(SocketAsyncEventArgs)
    9. DarkRift.Client.BichannelClientConnection:AsyncReceiveHeaderCompleted(Object, SocketAsyncEventArgs)
    10. System.Threading._ThreadPoolWaitCallback:PerformWaitCallback()
    11.  
     
  45. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Have a look at the log file in the server (or in Unity you could set the UnityConsoleWriter to output trace logs as that can be easier) for any more information. DR will disconnect clients under certain conditions if it thinks they're being malicious but will always output at trace level when it does so!
     
  46. Jihaysse

    Jihaysse

    Joined:
    Mar 29, 2020
    Posts:
    53
    Hey!
    I'm looking for a networking solution and found your Dark Rift which has great reviews.
    Before buying (even if I don't immediately need the Pro version, I still want to support great work!), I have some questions (I'm a total beginner in networking and yeah, my project may be ambitious but we all need a goal right?):
    1) Would it be suitable for a turn based MMORPG? I see most people using DarkRift for FPS/Matchmaking games or online multiplayers but limited to a few players.
    2) What advantage does DarkRift provide over - say Mirror or SpatialOS or PlayFab?

    Thank you for your time!
    Kind regards
     
  47. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    You can definitely build an MMORPG with DarkRift, but remember it's a big project with whatever networking system you use! A turn based game is singificantly easier than FPS' etc though!

    The key difference for DR is that it's a lot lower level than those. That means you won't be as restricted by DR but you will occasionally have to do more work with DR than in other frameworks.

    In the end, I always recommend just downloading the free version and trying it. If you like it, great! If you, don't then you've not lost anything :)
     
  48. RonTang

    RonTang

    Joined:
    May 20, 2017
    Posts:
    8
    Hi,I found only reliable and unreliable mode. Does DR2 has reliable udp inside it? Thanks for your attention.
     
  49. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DR2 uses TCP for reliable traffic by default but you can use a thrid party network listener to make DarkRift's reliable channel use Reliable UDP such as this ENET listener!
     
  50. RonTang

    RonTang

    Joined:
    May 20, 2017
    Posts:
    8
    Thanks Jamster for quickly response. I wonder why DR2 doesn't officially support RUDP for best speed.Is this on roadmap?