[Experimental] WebSocket Server


WebSocket Server

This library exposes a simple WebSocket server into FXServer.


  • Async
  • Text messages
  • Authorization header support



Convars available:

Name Type Default value Description
websocket_debug bool false Defines the verbosity of logs
websocket_host string “” Defines listening host
websocket_port int 80 Defines listening port
websocket_authorization string “” Defines accepted Authorization header value (auth disabled if empty)


Add a listener to receive messages

-- Add a new listener with a string parameter
AddEventHandler("WebSocketServer:onMessage", function(message)
    print("Received message: " .. message)

Send a message to connected WebSocket clients

TriggerEvent("WebSocketServer:broadcast", "This message will be broadcasted to all connected webSocket clients.");



  • Performance improvements
  • Async HTTP authorization handler
  • Less dependencies


  • Refactor onMessage event


  • Async
  • Text messages
  • Authorization header support


A photo or a longer description? … I have stayed the same I have no idea what this hahah serves : S


Ok i think i know what it’s for, but how would a broadcast be made to all customers? Could it be done by rcon?


It’s a server resource, I can’t provide any screenshot. :upside_down_face:

It’s up to you to broadcast WebSocket messages if needed. In your server script, add an event handler for WebSocketServer:onMessage and then broadcast received message to clients (you can add TriggerClientEvent("your:clientEvent", message) inside the event handler).
Same thing applies for RCON, if you need a command, add a new RCON command to your resource and trigger what ever you want.


I do not know the truth as it would, but I think it will be useful and will do great things !! Thank you :slight_smile:


Is it possible to broadcast live-sounds?

or what does it “broadcast” ?


Only text (string) messages. No binary messages yet.


It could be nice with live sounds!


Seems like people have no idea what you have created here, so let me be the first to say that this is brilliant! If I understand correctly, does this expose a WebSocket that can be approached by other applications? Or is this just for client server communication?


It’s exactly that, a WebSocket (server) that can be approached by other applications (with “real-time” two-ways communication).


Fantastic for a mobile application! Time to work.


God Damn! This has YUGE (trump) potential


A mobile application is at the origin of the creation of this resource :relaxed:


Great job so far! Might it be possible to also implement a Websocket Client so that it can connect to an existing server?


Unfortunately, this is beyond the scope of this resource.


Old topic but I am unable to change the port number where do I stick websocket_port


This is normal ?
Thank you for answering me as soon as possible :yum: