Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

DarkRift Networking 2

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

  1. osdima1

    osdima1

    Joined:
    Nov 4, 2019
    Posts:
    12
    Hello Darkrifters!

    Would appreciate your help pls.

    I am new to DarkRift..and I am stuck with this…

    I’ve built a basic standalone server(NET 6.0) and created a basic plugin(compiled with NET 6.0) which includes a nugget package-FirebaseAdmin.dll.

    Attached the code of my plugin.

    Once I run the server “dotnet Lib/DarkRift.Server.Console.dll”, I get an error-

    Code (CSharp):
    1. Unhandled exception. System.MissingMethodException: Method not found: 'System.Collections.Generic.IAsyncEnumerator`1<!1> Google.Api.Gax.PagedAsyncEnumerable`2.GetAsyncEnumerator(System.Threading.CancellationToken)'.
    This is my plugin code.

    Code (CSharp):
    1. using System;
    2. using System.Threading.Tasks;
    3. using DarkRift;
    4. using DarkRift.Server;
    5. using FirebaseAdmin;
    6. using FirebaseAdmin.Auth;
    7. using Google.Apis.Auth.OAuth2;
    8.  
    9. namespace plugin
    10. {
    11.     public class AgarPlayerManager : Plugin
    12.     {
    13.         public override bool ThreadSafe => false;
    14.         public override Version Version => new Version(1, 0, 0);
    15.         public AgarPlayerManager(PluginLoadData pluginLoadData) : base(pluginLoadData)
    16.         {
    17.             Start();
    18.         }
    19.         static async void Start()
    20.         {
    21.             System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "..../Projects/Firebase/service-account-file.json");
    22.             FirebaseApp.Create(new AppOptions()
    23.             {
    24.                 Credential = GoogleCredential.GetApplicationDefault(),
    25.  
    26.             });
    27.             await ListAllUsers();
    28.  
    29.  
    30.         }
    31.  
    32.         public static async Task ListAllUsers()
    33.         {
    34.             var pagedEnumerable = FirebaseAuth.DefaultInstance.ListUsersAsync(null);
    35.             var responses = pagedEnumerable.AsRawResponses().GetAsyncEnumerator();
    36.             while (await responses.MoveNextAsync())
    37.             {
    38.                 ExportedUserRecords response = responses.Current;
    39.                 if (response.Users == null) return;
    40.  
    41.                 foreach (ExportedUserRecord user in response.Users)
    42.                 {
    43.                     Console.WriteLine($"User: {user.Uid}");
    44.                     await FirebaseAuth.DefaultInstance.DeleteUserAsync(user.Uid);
    45.                 }
    46.             }
    47.  
    48.         }
    49.     }
    50. }
    51.  


    I assumed maybe the issue with the package itself, so I did a test without DarkRift server and the package worked with no errors.

    No idea what Im doing wrong..
     
  2. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    This definitely looks like an issue with a mismatched .NET version perhaps between the Firebase DLL and DarkRift.

    This page (ignore the security warning) gives some hints about the compatibility, I'm not sure it'll help you here but maybe it's a helpful reference.
     
  3. SEWRUS

    SEWRUS

    Joined:
    Jun 12, 2018
    Posts:
    1
    Hello! I really like your project, respect to you! Please tell me how to implement SendMessageToID in the second version of DarkRift2 (as it was in the first version). Or how to build an exchange of information between two players from several. Or sending a message from the server to a specific client. If possible, write an example with the code.
     
  4. Jamster

    Jamster

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

    DarkRift 2 is a bit different to DR 1 in that respect! In DR 2 you'll need to write a plugin for the server to direct traffic where you want it to go rather than reliying on the client to make the decision. If you have a look at the tutorial on the website you shouldn't need to go too far through to get a base you can work from for your game!
     
  5. FPSG

    FPSG

    Joined:
    Jan 8, 2014
    Posts:
    23
    Experiencing a major issue using DarkRift 2. The client keeps randomly disconnecting from the server and the server never gets notified of this error.

    This disconnection is super random and when it happens, the client thinks it disconnected successfully but the server still thinks the client is connected.

    Using TCP to send messages. There are no errors whatsoever either. Any ideas?
     
  6. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    I feel like this might have been fixed in a recent version, make sure you're using the latest version from GitHub. If it's still an issue then maybe try creating an issue or asking Unordinal in the Discord!
     
  7. FPSG

    FPSG

    Joined:
    Jan 8, 2014
    Posts:
    23
    I'm using 2.10.1, far as I'm aware that is the latest stable version?
     
  8. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    You can get the latest version from GitHub here. Technically the latest version is 2.11.0 but it looks like Unordinal have only put the 2.11.0 package on NuGet for some reason
     
  9. FPSG

    FPSG

    Joined:
    Jan 8, 2014
    Posts:
    23
    Just updated to 2.11.0, unfortunately the issue still occurs :(
     
  10. FPSG

    FPSG

    Joined:
    Jan 8, 2014
    Posts:
    23
    Some more info:

    The client connects to the master server, which is completely fine and doesn't cause this issue.

    Once the client opens a new connection to the game server where all the players are playing, then only the game server connection gets dropped without the server being aware. The connection to the master server still works.

    I'm using the following modification in the config to run the master server and game-server instances within the same dedicated server:
    Could the 2 simultaneous connection to a dark rift server be the problem?
     
    Last edited: Feb 21, 2023
  11. spootymilk

    spootymilk

    Joined:
    Jun 9, 2017
    Posts:
    18
    Hi,
    We are implementing DarkRift to our game. If we build a Windows server, locally everything is working as expected.

    On the linux server, using Unity 2021.3.14f1 with a dedicated server build, the connection fails.
    The server Logs :

    [Trace] DefaultNetworkListener Accepted TCP connection from X.X.X.X:54968.
    [Trace] DefaultNetworkListener Connection attempt from X.X.X.X:54968 timed out.

    What can cause that ?

    EDIT : Found the solution, I've open only the TCP port, it need both TCP and UDP.
     
    Last edited: Mar 11, 2023
  12. rafayel_zealous

    rafayel_zealous

    Joined:
    Nov 21, 2018
    Posts:
    11
    Hi Jamster.
    I'm trying to play around with the Darkrift free version. I should say it's nice to have one.
    I have a small point I can't figure out, is there any way to run the server from Unity editor or a built application?
    Thanks!
     
  13. Ruslank100

    Ruslank100

    Joined:
    Apr 11, 2018
    Posts:
    46
    Yes you can run an embed server with the XmlUnityServer component
     
  14. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    514
    Here is my configuration setup

    Linux Dedicated Server Setup (Dark Rift 2)

    Introduction
    This guide deploys a Unity - 2023.1.8 Linux dedicated server build using Dark Rift 2 to a Contabo standard VPS (Not Managed) Unbuntu 20.04-LTS x64.

    Pre-requisites
    • Unbuntu 20.04-LTS x64
    • UFW Firewall
    Instructions
    Upload dedicated server build created by unity
    • Upload build folder to the VPS server e.g. ../root/serverbuild
    Open tcp and udp ports for the dark rift network listener
    Set this to the listener port you choose

    sudo ufw allow in 4200/tcp
    sudo ufw allow out 4200/tcp
    sudo ufw allow in 4200/udp
    sudo ufw allow out 4200/udp
    sudo ufw status
    Set executable permissions for the server file
    chmod +x server.x86_64
    Create the service configuration file
    nano /etc/systemd/system/server.service[Unit]
    Description=Server
    [Service]
    ExecStart=/root/serverbuild/server.x86_64
    Restart=always
    Group=root
    WorkingDirectory=/root/serverbuild
    [Install]
    WantedBy=multi-user.target
    Service operations
    • Start the service
    systemctl start server
    • Required to enable server on reboot
    systemctl enable server
    • Other commands
    // Stop the service
    systemctl stop server
    // Service configuration updates
    systemctl daemon-reload
    // Show running services
    systemctl --type=service --state=running
    // Show logs
    systemctl status server
     
  15. r137

    r137

    Joined:
    Mar 12, 2018
    Posts:
    47
    Hi, the website is down for a few days. Is there an alternative location for the documentation?