Comments (15)
Oh yay! That works perfectly yes. Thanks so much man! You are awesome! :)
from bytexdigital.battleye.rcon.
Please help :( I am still trying to figure this out.
I can make a rcon connection, but as soon as the Fetch command start running the application freezes and won't return the players count. Is the code below incorrect? Strangely enough when there are 0 players then the count shows 0 and no freezes..
//Connection info
RconClient networkClient = new RconClient("192.168.1.105", 2320, "12345");
networkClient.Connected` += NetworkClient_Connected;
// Connect
networkClient.Connect();
// Optionally make sure we are connected
networkClient.WaitUntilConnected();
var requestSuccess = networkClient.Fetch(
command: new GetPlayersRequest(),
timeout: 5000,
result: out List<Player> onlinePlayers);
if (requestSuccess)
{
label_count.Text = onlinePlayers.Count.ToString();
}
else
{
label1.Text = "Disconnected from Rcon";
label_count.Text = "Playing Err/60";
}
from bytexdigital.battleye.rcon.
Hi, I'll get you a working example once I'm back home later today, have you tried debugging whether maybe it gets stuck at WaitUntilConnected?
from bytexdigital.battleye.rcon.
hey, thanks so much for the reply! Much appreciated!
I did comment out WaitUntilConnected, but same things happens.
from bytexdigital.battleye.rcon.
Try putting in Console.WriteLine before and after the WaitUntilConnected to check whether it gets stuck there or after it
from bytexdigital.battleye.rcon.
Okay i did this and it got stuck at the Fetch command. I never got the last message box.
MessageBox.Show("This is before wait");
networkClient.WaitUntilConnected();
MessageBox.Show("This is after wait");
bool requestSuccess = networkClient.Fetch(
command: new GetPlayersRequest(),
timeout: 5000,
result: out List<Player> onlinePlayers);
MessageBox.Show("This is after Fetch");
from bytexdigital.battleye.rcon.
But also once again, when the server is empty then the output shows 0 and the application does not get stuck. Weird hehe
oh and by the way, I am using Windows Forms and not console. If I use BytexDigital.BattlEye.Rcon.TestClient then it works perfectly fine. So maybe it just does not work with Forms?
Remember I am trying to display the count in a Label/RichTextbox.TextBox. Which ever one will work.
from bytexdigital.battleye.rcon.
Do you use Windows Forms on .NET Core or .NET Framework?
from bytexdigital.battleye.rcon.
Please also try putting your code into a try catch and putting a break point/printing the Exception that might get thrown. Maybe an exception is being thrown that is just not appearing visible to you, which is why your MessageBox is never shown. Sometime like this:
try
{
MessageBox.Show("This is before wait");
networkClient.WaitUntilConnected();
MessageBox.Show("This is after wait");
bool requestSuccess = networkClient.Fetch(
command: new GetPlayersRequest(),
timeout: 5000,
result: out List<Player> onlinePlayers);
MessageBox.Show("This is after Fetch");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
from bytexdigital.battleye.rcon.
Hey
I tried that and still the same problem. After the FETCH command the app hangs and does not even get to the exception part. Strangely enough, when I connect to my local dayz server it always gives me 0 as the player count even if there is 1 player online. The app does not hang then. Only when I connect out to my actual live server does the app hang. I can use any other Rcon tool to connect to my server and that works perfectly fine.
I am using .Net Framework 4.8. Previously tried it on 4.7.2 and VS2019, but now I am using VS2022 and new Framework 4.8.
Code which I tried to use is like this now:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using BytexDigital.BattlEye.Rcon;
using BytexDigital.BattlEye.Rcon.Commands;
using BytexDigital.BattlEye.Rcon.Domain;
namespace RconTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
RconClient networkClient = new RconClient("192.168.1.105", 2320, "12345");
private void rconConnect()
{
// Connection Info
//networkClient.MessageReceived += NetworkClient_MessageReceived;
networkClient.Connected += NetworkClient_Connected;
// Connect
networkClient.Connect();
// Optionally make sure we are connected
try
{
MessageBox.Show("This is before wait");
networkClient.WaitUntilConnected();
MessageBox.Show("This is after wait");
bool requestSuccess = networkClient.Fetch(
command: new GetPlayersRequest(),
timeout: 5000,
result: out List<Player> onlinePlayers);
MessageBox.Show("This is after Fetch command");
if (requestSuccess)
{
label_count.Text = onlinePlayers.Count.ToString();
MessageBox.Show("Request Successfull");
}
else
{
label1.Text = "Request not successfull";
label_count.Text = "Error";
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
MessageBox.Show("This is after TRY command");
}
private void NetworkClient_Connected(object sender, EventArgs e)
{
label1.Text = "Connected to Rcon";
MessageBox.Show("Rcon Connected!");
button_connect.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
rconConnect();
}
}
}
from bytexdigital.battleye.rcon.
It seems that .NET Framework breaks something in the functionality of this library. If you are able to, I suggest you switch your project to .NET 5 instead (for example using this guide https://docs.microsoft.com/en-us/dotnet/desktop/winforms/migration/?view=netdesktop-6.0) or by creating a new project with .NET 5 WinForms selected. I'm afraid I cannot reproduce the issue with .NET Framework 4.7.2, so it is hard for me to help.
from bytexdigital.battleye.rcon.
Hey there, I created a new project and selected .Net 5 Windows Application. Setup a small test again, same as before and still the same thing happens. Application gets stuck at the Fetch command.
Gets stuck after: MessageBox.Show("This is after wait");
from bytexdigital.battleye.rcon.
@rjclarkewp007
I had the same issue. It can be solved by making rconConnect an async function and using async version of Fetch.
Try using it like that:
var onlinePlayers = await networkClient.FetchAsync<List<Player>, GetPlayersRequest>(new GetPlayersRequest(), new CancellationToken());
Then onlinePlayers.Item1 will be the bool result and onlinePlayers.Item2 the List of Player objects.
Hope it helps.
from bytexdigital.battleye.rcon.
@rjclarkewp007 I had the same issue. It can be solved by making rconConnect an async function and using async version of Fetch. Try using it like that:
var onlinePlayers = await networkClient.FetchAsync<List<Player>, GetPlayersRequest>(new GetPlayersRequest(), new CancellationToken());
Then onlinePlayers.Item1 will be the bool result and onlinePlayers.Item2 the List of Player objects. Hope it helps.
Hi, thanks for the reply. I tried this, but I receive an error for FetchAsync:
If I remove the async from Fetch, then I still have an error:
from bytexdigital.battleye.rcon.
@rjclarkewp007 what version you are using? If 1.0.2 stable, upgrade to 1.0.3 preview version via NuGet manager. I get same error as you on 1.0.2 version but on 1.0.3 it works perfectly fine ;)
from bytexdigital.battleye.rcon.
Related Issues (10)
- How to define kick reason? HOT 5
- disconnects every 12m 56s HOT 4
- A onlinePlayers BUG? HOT 12
- [DayZ] one instance connecting multiple times? HOT 12
- GetMissionsRequest doese not realized HOT 7
- Cyrillic support HOT 9
- SocketException HOT 4
- GetPlayersRequest always return an empty list HOT 10
- Connection interruption due to wrong sequence number HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bytexdigital.battleye.rcon.