Error with HTTP Service

In my game, I have a feedback system where players can send feedback to a discord webhook. When attempting to send feedback, I get a HTTP 429 error code.


Is there any way to fix this?
The Invalid player to teleport. warning is not related to this.

I cannot know how your code works, but this HttpService error appears when one sends to many network requests. Current restriction is 500 requests per minute, so it seems like you are exceeding that number. Try restructuring your code and sending less requests while perhaps also adding a “cooldown”.

EDIT @zezegooglekid can you please paste the relevant part of your code? Without further information, we can’t help.

1 Like

There is a 3 second cooldown in the code. The 500 requests per minute you said certainly has not been met as I have only tested this about 10 times in 5 minutes. I have tested this on 2 accounts, and I have not gotten any feedback today. I have no idea why this is happening.

Try adding a print statement in your code to check how many request are being sent. It’s a crude method but requires little code and helps you see roughly the amount of request per second.

If you want something more in-depth then you can use something like this in whatever loop you are most likely using:

local start = DateTime.now().UnixTimestampMillis -- The time at the start of your code

-- Other code HTTP request and such

local endTime = DateTime.now().UnixTimestampMillis - start
print(endTime)

1 Like

Gotcha,

FeedEvent.OnServerEvent:Connect(function(player, text)
	if table.find(used, player.UserId) ~= nil then
		return
	end	
	
	if table.find(banned, player.UserId) ~= nil then
		player.PlayerGui.Feedback.Frame.Banned.Visible = true
		wait(2)
		player.PlayerGui.Feedback.Frame.Banned.Visible = false
		return
	end
	
	local data = {
		['embeds'] = {{
			['title'] = "đź“© "..player.Name.." has sent feedback! Their id is "..tostring(player.UserId)..".",
			['description'] = tostring(text),
			['color'] = 0
		}}
	}
	local finalData = httpService:JSONEncode(data)
	httpService:PostAsync(webhookURL, finalData)
	table.insert(used, player.UserId)
	if player.PlayerGui:FindFirstChild("Feedback") then
		player.PlayerGui.Feedback:Destroy()
	end
end)

The cooldown is on the client by the way.

I feel like you are using HttpService for sending various data from different scripts. These limits are not bound to one script, but rather the whole server.

EDIT @zezegooglekid @BuilderBob25620 I’m taking about possible use of HttpService for sending other data. Do you perhaps have an external data store set up? You can only send 500 requests per minute from a single server.

Here is how to protect remote events server-side:

local lastSignal = {}
local LIMIT = 5

-- Usage:
if (os.clock() - (lastSignal[player.UserId]) or 0) < LIMIT then return; end
lastSignal[player.UserId] = os.clock()

-- When player leaves:
lastSignal[player.UserId] = nil
1 Like

That’s a terrible coding practice and should almost always be avoided. Whatever is on the client can be controlled by the client (exploiters, hackers, ect.). You should instead send the relevant information through a remote event to the server and then have the server execute the cooldown.

2 Likes

You are correct, I am using a TextBox and a local script, the local script fires a remote event with the text in the text box, which the server recieves and does a request to the discord webhook.

Very good point. I normally have a tension with the client and normally don’t trust it(as i should), don’t know what happened with me back there.

Also, I think the code the client uses is more relevant in this situation, so we may need it.

Alright,

send.Activated:Connect(function()
	if box.Text == "" then
		return
	else
		local text = box.Text
		event:FireServer(box.Text)
		game.SoundService.feedback:Play()
		send.Active = false
		send.BackgroundColor3 = Color3.new(0.290196, 0.290196, 0.290196)
		send.Text = "Disabled"
		send.Active = false
		wait(5)
		send.BackgroundColor3 = Color3.new(0.407843, 1, 0.262745)
		send.Text = "Send"
		send.Active = true
	end
	
end)

image
Just tested it in studio seems to work. If I publish it then I will mark this as solved.

Nope. This text will be blurred

It works now. Thank you for your help, @BuilderBob25620 thank you for your advice on the cooldown, I will put it on the server as you said I should.