
Jira Integration & Graphical Test Builder
We are proud to announce the release of two new features, available immediately. 🚀 Jira Integration: Automate Issue Tracking for...
Guide on load testing WebSocket-based applications with LoadForge using Locust.
You are now browsing the LoadForge locust test directory. You can use these tests as a starting point for your own tests, or use our AI wizard to generate one automatically.
LoadForge provides support for generic WebSocket testing via the WebSocketUser
from locust-plugins
. You can open WebSocket connections, send and receive messages, and simulate concurrency to measure performance under load.
# locust.py
import time
from locust import HttpUser, between, task
from locust_plugins.users import WebSocketUser
class MyWebSocketUser(WebSocketUser):
wait_time = between(1, 3)
host = "wss://YOUR_WS_URL_HERE"
def on_start(self):
# Connect to WebSocket server
self.connect("/ws")
@task
def send_message(self):
# Send a message to the WebSocket
self.send("hello", name="SendMessage")
# Optionally wait for server response
time.sleep(1)
def on_message(self, message):
# Handle incoming message
print(f"Received: {message}")
if __name__ == "__main__":
from locust import run_single_user
run_single_user(MyWebSocketUser)
Notes:
pip install locust locust-plugins websockets
if you wish to test locally.YOUR_WS_URL_HERE
and endpoint /ws
with your actual WebSocket URL and path.