LofentaLofenta/Docs

Domains & networking

WebSockets

WebSockets work out of the box on Lofenta. Any app that accepts a WebSocket upgrade is reachable over wss:// on its *.lofenta.app URL and on any custom domain, with no extra configuration.


How it works

Every project sits behind a reverse proxy that forwards the WebSocket Upgrade handshake straight through to your container. Cloudflare, which fronts every project, allows WebSocket traffic on all plans. You do not need to open a port, set a flag, or tweak any proxy setting.

  • No buffering. Frames are streamed in both directions as they arrive, so latency stays low.
  • Long-lived connections. There is no idle timeout that drops a quiet socket. Send your own pings if your client needs them.
  • Same server, same port. You can serve HTTP and WebSockets from one process on a single port.

What your app needs to do

The same rules as any HTTP app apply, nothing WebSocket-specific:

  • Listen on the port Lofenta provides in the PORT environment variable.
  • Bind to 0.0.0.0, not 127.0.0.1.
  • Accept the upgrade on whatever path your client connects to.

Connecting

Use wss:// (TLS is always on) against your project URL or custom domain:

const ws = new WebSocket("wss://my-project.lofenta.app/ws")
ws.onopen = () => ws.send("hello")
ws.onmessage = (e) => console.log(e.data)

Always use wss://, not ws:// — plain WebSocket connections are redirected to TLS, and browsers block insecure sockets on an HTTPS page.

A dedicated WebSocket server

If you want a ready-made realtime backend instead of writing your own, deploy the Soketi template: an open-source, Pusher-compatible WebSocket server. Lofenta wires its credentials automatically so a Laravel or any Pusher-compatible client can connect with no manual setup.

WebSocket services are subject to the same Acceptable Use Policy as the rest of the platform.