Roblox websockets - ROSOCKET

ROSOCKET

Hello devforum! I have made a module to replicate “websockets” in roblox that only requires a bit of knowledge to know how to set up (if you want to self host). If you don’t have somewhat knowledge on this, all you need to do is Enable HTTP Requests, and you’re good to go!

The module includes dependecies like “Maid”, “Signal” which are already known and made by other big developers. Custom modules are “Signature” and “Reader”, which are used for custom utility of the module. The signature module provides the watermark/text format, and the reader module provides help retrieving/sending data to the endpoint of the server of your choice. You can set up the node server, then deploy it, and change the backend URL to yours, meaning your server will take routes and will connect to the websockets themselves.

It’s a older project of mine that I have finished yesterday, even tho it started 5 months ago back when I didn’t have money to deploy a custom server. Below is a summary list with some details regarding the module:

Current features Creating a new socket object connection.
Sending data to the socket.
Reading data from socket.
Signals that get fired on each new message received (and also when disconnecting the socket).
Disconnection support.
Features that I think of adding Custom binary type support, which the server will read and connect to the websocket in that provided binary type.
Remove the Connect function directly from the module, add a New function which creates a socket object, then move over the Connect function to the created socket object, and add a OnOpen event, and some error checking such as opening a already opened socket

You can find it here: RoSocket · GitHub
Please star it if you like it, and give me some feedback on it. Thanks!

11 Likes

I’d argue it’s a great tool, but I don’t find much usage for it while in game, how would you use it?

2 Likes

hello dottik my beloved, this can be used for more projects, such as a join logger, instead of posting to a proxied webhook directly or to your endpoint, you can open a websocket on your vps, then make a string splitter to handle cases such as “LOGUSER-userid1234”, and if its LOGUSER then it will send the data to the webhook

1 Like

Ahh, so if your hooks get leaked it wouldn’t be much of a disaster, good one, although binary support would be great, imagine if I could catch errors live on a server console, that would be 10/10.

As in, imagine you have s bug you just CANNOT get because it requires REALLY precise things for it to happen, using this I’d probably find it on live games no problem with my own app, without depending on things like Discord Webhooks or other form of Webhooks in general, all in house, got leaked! Just change part of the websocket handshake for example! Voila, no more Webhooks spam.

1 Like

took me a while to understand what you’ve said but, there’s already a error handler in the latest release (v1.0.1)

No, I meant that you can catch the error on production using ScriptContext.Error, and relay it so you as a dev can join and check what’s going on

well, thanks for the suggestion, please star the repo if you can since this is getting no attention :sad:

Honestly, I was going to create one in Python and use Quart as my framework. Just have one endpoint that accepts GET/POST, so I can POST to the Roblox Server and then GET that data back.

Haven’t had time to do it fully.

1 Like

it’s easy to make, there’s already another one called unisocket but i’ve never used it, but based from the code its kinda unoptimized, its all the same method which is long polling

This and long-polling are two completely different things, Long-polling will use extra resources and might strain your server, while WebSockets and API will do on request.

1 Like

long polling is the method im using for this module, and i didnt say a websocket and long polling are same things if thats what you mean

I use this everyday, thanks zirt for making this wonderful websocket module!

1 Like

Fellow devs help each other, and this is a great addition to my toolkit

1 Like

Thank you for the feedback, and yes developers help each other, we gotta keep the community nice at any time!

I am running a self-hosted express server, and a wss.
Both are running perfectly and transferring data between themselves with no issue even with an artificial OpenSSL.

However in ROBLOX it just does not work.
Keeps erroring: “HttpError: Timedout” as if i’m not getting any response from my server?

What you should do is use MessagingService for comms towards Roblox, and then yes use HTTP for comms back to the server.