I don’t really know if this is a bug or if this is just me being stupid but I’m having a tough time posting a URL in C# on FiveM.
Problem: Everytime I run to post the URL, it freezes the then I have to timeout the Task for it to keep the server running. If I never timed out the task, it would just keep trying to “post” until I restarted the server. I’ve tested the URL I’m trying to post and it works just fine with an external website (haven’t tried C# on my PC yet).
My current code:
private static async Task<string> PostAsync(string url, Dictionary<string, string> args)
{
Log.WriteLine("http");
using (var client = new HttpClient())
{
Log.WriteLine("Content");
var content = new FormUrlEncodedContent(args);
Log.WriteLine("PostAsync");
var res = await client.PostAsync(url, content);
Log.WriteLine("ReadAsync");
var resStr = await res.Content.ReadAsStringAsync();
Log.WriteLine("Return");
return resStr;
}
}
I have also tried legacy methods, WebClient, and Flurl.Http for posting the website, all freeze the system.
The log writes are just to know when it freezes and it freezes right after the “PostAsync” message.
If someone has knowledge of how I could do this within mono and a FiveM server that would be nice
My system specs (if important):
Ubuntu Server 17.10
4gb RAM
Unknown processor (VPS won’t tell me)
Hoster: OVH