Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can you connect roblox to a websocket?

Would it be possible to connect to a websocket with roblox? I don't need directly, like say GetAsync my website with the javascript websocket, but it doesn't keep the connection. If you wanna know what I'm using this for it is a "Roblox hosted discord bot" I've already got a working version and it does what I need it to, but a way to do some type of connection with a websocket or someting would boost this a lot.

Here is the "websocket" connection I attempted

local http = game:GetService("HttpService")
spawn(function()
while wait(3) do
http:GetAsync("private_url")
end
end)

The reason that failed is because of two reasons

  1. For the bot to stay online/etc it'd have to be constant connection
  2. I have to wait 1-2 seconds until I can connect to the websocket

3 comments

0

You only have access to the protocols http and https you cannot use any other protocols

0

The ROBLOX HTTPService cannot have a keep alive(maybe) but once it completes it's request, it is terminated immediately. Why can't you just run a server on your computer, portforward them? ISP problems? server problems? I might able to fix 'em

0

I don't have the tools to do so, this isn't my laptop since mine broke so I don't wanna download stuff, but this laptop is also too slow for any of the normal bot creation tools (vs,node,etc)

1 answer

try this

local http = game:GetService("HttpService")

spawn(function()
	local maxReqPerSec = 3
	while this.alive == true do
		local tm = tick()
		http:GetAsync("your_url")
		local dur = (tick() - tm)
		local waitTime = math.max(0,((1/maxReqPerSec) - dur))
		wait(waitTime)
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.