HTTP Requests keep 404ing

Hey!

I like working with Node.js and making APIs. But recently, I’ve run into this problem where half the requests I send aren’t ever reaching any of my servers. For instance, I have this small project I’m working on right now. When I test my game in Studio or in-game, my request never goes through for some reason. When I check Server HTTP Requests in Developer Console, I find this:

Strangely, my server never reports any requests to have been sent.

This isn’t the only instance of this happening. I’ve done work for two different groups, one of which I made a place that has a script that fires a request to the web server as soon as someone joins the game. Half the time I join the game, none of my HTTP Requests work, including that one. I have to rejoin a couple of times to get a different server so it can work.

1 Like

on your nodejs app,

are you doing

app.get("/announcements", func ... etc)

or

app.post("/announcements", func... etc)

I have both endpoints on my Koa API router. However, I’m just using the GET at the moment. The problem isn’t with that because it works half the time and regardless of where I’m targetting, the morgan middleware catches it all requests sent on the port.

Are you using any proxies? like cloudflare?

Perhaps you should use the new Http RequestAsync to get headers, etc. see if they return information that could be helpful. Also the output of the request, perhaps the router isnt picking it up for some reason
http://robloxdev.com/api-reference/function/HttpService/RequestAsync

I use Cloudflare for things in production. I’m not using it for this small project.

I used RequestAsync and it’s working at the moment, however, I think it’ll wind up just like the GetAsync where it works only half the time.

do you know what the body of the requests are returning?
in express it should have like “Cannot get /announcements”, it might help if it returns that, you could do a
simple catch all function on express like so, this will make 100% sure you are not getting the requests at all

app.use(function(req,res,next){
   console.log(req.originalUrl + " was called")
   next()
});

I’m using Koa which is kind of Express v5. The morgan middleware informs me of all hits that happen. So if I were to GET /nonexistentendpoint and /nonexistentendpoint is not routed anywhere, it would tell me that there was a GET request and it gave a 404. I am 100% sure that the requests aren’t coming at all.

Well make sure RequestAsync works, and if it doesn’t half the time, output all the data it returns to see if we can narrow it down.

It happened again, here’s what the console shows.

The server shows:

HttpError_Conenct :laughing: roblox messed up error.
So the last announcement returned a 200 code, and also errored?

No, the last batch of announcements were received and it worked. However, when I tried to get them again, the request never hit the server. It just showed that in the console.

Ahh i see, where are you hosting it? if at home, just note that ISPs dont like people hosting websites on residential connections (if that’s what you’re doing). I’ve experienced this in the past with my ISP

You’re also using HTTP and not HTTPS correct? i see in the images in the OP it says HTTP, just want to make sure though.

Let’s not tell my ISP what I’m doing :eyes:. It’s not a permanent thing, just temporary while I make my thing work so I don’t have to constantly re-upload the file back up to my VPS every time I make a change. However this can’t be the problem because it also happens to my other stuff which are on my VPS.

I am using HTTP, that is correct.

Alright, could you show some code (with redacted domain) how you’re sending it?
i can’t think of anything that would be causing it

Here’s the code:

local response = HTTPService:RequestAsync({ Url = 'http://hahaha.net:3333/announcements' });
	
for a,b in pairs (response) do
	if (type(b) == "table") then
		for c,d in pairs (b) do
			print(c, d);
		end;
	end;
    print(a, b);
end;
	
-- Inspect the response table
if response.Success then
	print("Status code: " .. response.StatusCode .. " " .. response.StatusMessage)
	print("Response body:\n" .. response.Body)
else
	print("The request failed: " .. response.StatusCode .. " " .. response.StatusMessage)
end	
	
data = response.Body;

Do all your apps with this issue not use port 80 (default) to connect?

Yes, I use ports 3334 and 3333 mainly. I reserve port 80 for Apache.

I see, well you can setup a reverse proxy on apache (not sure the config as I use Nginx personally), but it’d allow you to use multiple domains on virtual hosts, so when making requests with domain hahahaha.net it’ll automatically route to your node app, that’s what I do for my production APIs via expressjs

Not entirely sure if using ports other than 80/443 would be the issue, if it is, then it’s entirely roblox’s fault, or it’s got to be. No reason why it shouldn’t connect. I also tested some code myself to random non-existant domains, and the error codes are not super helpful (like telling you whether its a DNS error, connection refused, etc.)

This tutorial might help https://www.1and1.com/cloud-community/learn/application/misc/set-up-a-nodejs-app-for-a-website-with-apache-on-ubuntu-1604/

after setting up a reverse proxy, if it’s still an issue, you might want to work with an engineer to solve it.

I don’t think I need a reverse proxy. I don’t use multiple domains either, I just create/remove subdomains with Cloudflare.

I’m using No-IP right now to map a free domain to my public IP with a port forward on port 3333. It does seem like Roblox’s fault because no matter how many times I spam my API with Postman or my browser, it always resolves and gives me a response.

Reverse proxy just makes it so you can use multiple domains on the same port, but if you dont want to, do what you want i guess :stuck_out_tongue:

It could entirely be a DNS resolve issue on roblox’s side, or even the DNS provider is limiting how much they can do it (as far as i know, roblox doesnt cache DNS based on my experience), so try using a direct ip to the host so like http://192.168.2.1/example and see if the issue continues