I have been experiencing this issue where HttpService will not deliver the response if a player leaves the game or the game server shutdown, so many of my requests fail without notice. Most of our applications have not been delivered properly, and as a result most of our players’ appeals, or applications have not been sent if they leave.
Minimum Code Example:
This is only works with an API endpoint that is a POST request - I don’t have one that is easy of access, so I’m just going to use dummy data. This uses RequestAsync though it works with GetAsync, PostAsync
local http = game:GetService("HttpService")
local res = http:RequestAsync({
Url = "https://api.example.com/users",
Method = "POST",
Headers = {
["Content-Type"] = "application/json"
}
})
print(res)
Let me know if you need anything else - I’ll be happy to provide it if need be.
This really didn’t help because if the player leaves, then the request will drop and there goes the data. I was using the new BindToClose API to detect if they left and then try to get that data to be completed before it drops the request.
The request only takes around 2-10 seconds (depending on the player’s internet connection and roblox servers at the time), which might play a factor in this case - not sure entirely.
So, as I understand it, you are using this system to handle applications for something similar to group ranks or jobs, where a player joins a game and the game handles their fill-out form?
Has this ever worked flawlessly before, i.e. is it a more recent issue?
When the last player leaves a server, that server wants to close ASAP to open up server space for others. I’ve had HTTP requests trying to fire right at server closing before as well, and I found it just simply isn’t feasible to trust that the server is going to keep itself up long enough to complete all of your requests.
I highly recommend that you add some “fluff” at the end of your application process before the player leaves. If I did this, I would make sure the player is told to sit tight for a minute before either telling them they can leave, or kicking them from the server. This will give the request some time to be sent.
HTTP requests are funky sometimes, because they not only rely on Roblox’s servers (which are funky enough as is), but they also rely on other sites’ servers, and it is difficult to guarantee their efficiency. So, when using them, you definitely want to have fluff in your code when possible.
I don’t believe there is a way to confirm that an HTTP request was sent successfully; someone else will have to chime in if this is possible. But if it is, I’d have your application system hold until it got that confirmation before instructing or forcing the player out.
The problem is, if I add UI text, people are most likely not going to read it - hints why this is important. We cannot force the player to stay and the request will just end without delivering it a 200 status code.
This is not the first time, we’ve had solutions but those solutions are reliant on the player to do their part of reading.