I’ve been trying to make a webhook using a proxy server of mine using the fetch library of nodejs. Unfortunately it doesn’t seem to be working at all, and all I’m getting are 504 errors which are extremely difficult to debug. Any suggestions on why the server.js script isn’t sending the request body to the discord webhook?
-- Roblox script:
local response = HTTP:RequestAsync({
Url = ,"discord.com/webhook/029302932034013"
Body = HTTP:JSONEncode({["username"] = plr.Name,
["content"] = "test"}),
Headers = {
["Content-Type"] = "application/json",
},
Method = "POST"
})
-- the code below does not run until the 504 gateway timeout appears in console.
if response.success then
print("Status Code:", response.StatusCode) -- prints 504 gateway timeout
else
print('The request failed:', response.StatusCode)
end
504 Gateway Timeout server error response code indicates that the server, while acting as a gateway or proxy, did not get a response in time from the upstream server that it needed in order to complete the request. In short the request is not being processed quickly enough
Thanks as well, I’m aware that it means the proxy didn’t respond within a reasonable timeframe, but can I confidently assume that means there were no errors with my nodejs code and rather a permanent yield? When I attach a .catch to the fetch function that doesn’t fire any response back either so it must be hanging at the fetch call line. Any guesses on what might’ve gone wrong in that case?
Well form the js code you shown you are not sending back any status code response and that is causing the request to go through but roblox to think that you haven’t handled the request in time throwing error 504
The worst part is that it just returned a 504 gateway and no errors. I did have a catch statement for the fetch (I’m using axios instead now which works) but the catch didn’t fire the error response.
I had to run a nodemon local server to see the bug, which I suppose that’s what I was supposed to be doing the whole time(new to this lol)
Asumming you’re using a try catch block, you have to throw a new error when res fails. So that the catch block fires. Alternatively you can just remove the await from the axios request and add in a .catch() that’ll fix it to.
Pretty much this. But I assume since fetch was never defined it just hangs there indefinitely? I never once got an error 400 returned to roblox studio. (Also assume the link in the lua script is my proxy)
I have it working now with axios, I looked up why it wasn’t catching the ‘fetch not defined’ error and its because a promise was never created in the first place since the program errored before it could be created.