Receiving HTTP requests in Roblox?

I am 99.99999% certain that this isn’t possible, but I want to be 100% sure. What if the game server sent an HTTP request to my web server, and my web server used that request to get the IP of the server to send requests to? Is there any way at all you could create a custom way of listening for HTTP requests within Roblox? Even if it’s super hacky?

You could always get Roblox to send a request to your server every X seconds, and then the server responds to the request when it needs to. If the request times out, the server sends another. If the server receives a response then it sends another and waits for more responses. This works fine in most cases, but I want to know if there is a more efficient and reliable way?

3 Likes

No, this is not possible.

3 Likes

And there isn’t even a super hacky custom implementation? Aside from what I mentioned.

The only solution is polling from the server, AKA what you mentioned.

2 Likes

Okay, thanks.

Edit: Probably going to make a module which makes implementing the method I said easy and open source it. Thanks!

2 Likes

Do you have any idea how long it takes for HTTP requests to timeout? It doesn’t say on the wiki and can’t find anything on Google… :thinking:

1 Like

curl has a timeout of 2 minutes (how roblox sends requests), and it also depends on your web server setup. nginx will hold requests just fine (if you configure it to do so), but if its through cloudflare, it will timeout pretty fast.

I’m a little confused.

I am using Express on Google App Engine. If Roblox sends a request to the server, Roblox will timeout after 2 mins, correct? Does the time it takes for Cloudflare, etc, effect that (I am considering using cloudflare).

1 Like

I haven’t tested express timeout (even though i use express), I based the 2 minutes off the default curl timeout, and the fact i’ve used long polling previously without issue on roblox’s end. Cloudflare will return an error if the origin doesnt respond within 15 seconds.

For my personally, i just poll every 15 seconds, send information, and receive information, works quite well.

Okay, thanks. I am considering creating some crappy implementation of a game server on Roblox as a proof of concept. That’s why I need this. Thanks for the help!

You can achieve the desired functionality with HTTP long polling. Here’s a blog post about it: https://www.matthewdean.com/sending-data-to-roblox-game-servers-in-real-time-using-http-long-polling

3 Likes

Thanks! It’d be nice to see a proper implementation, though. Obviously not any time soon. Is anything like that on the roadmap?

WebSockets would be a nice addition also.

3 Likes

I agree, however the idea was rejected.

1 Like

Or possibly Webhooks.

2 Likes

That was posted quite a while ago, without any information regarding how exactly it was a security issue.

The situation may have changed now.

This is very helpful, thank you! However one concern I have is that won’t sending requests in a while loop hit a brick wall in terms of rate limits roblox-side?

1 Like

Not if you send under 500 requests/min.

Honestly, i think they misinterpreted it. I wanted a client-implementation, like the roblox server makes an outgoing socket to our own server, instead of us making a socket to the roblox server. Could be wrong.

3 Likes

Just make a REST api and make your game listen for new data and if its new it does something