Receiving HTTP requests in Roblox?


#1

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?


#2

No, this is not possible.


#3

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


#4

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


#5

Okay, thanks.

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


#6

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:


#7

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.


#8

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).


#9

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.


#10

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!


#11

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


#12

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


#13

WebSockets would be a nice addition also.


#14

I agree, however the idea was rejected.


#15

Or possibly Webhooks.


#16

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

The situation may have changed now.


#17

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?


#18

Not if you send under 500 requests/min.


#19

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.