The tool is a simple client for WebSocket. It simulates multiple client endpoints and sends/received messages to/from a WebSocket server. It can be used to test WebSocket listeners of an API Gateway. Check Axway API Gateway documentation to configure WebSocket connections.
The default behavior is to send a single text message to the ws://localhost:8025/echo
endpoint.
This is the default endpoint of the simple WebSocket server.
$ java -jar ws-simple-client-0.2.2-jar-with-dependencies.jar
INFO 10:29:06.452 - Connect to URI: ws://echo.websocket.org (1)
INFO 10:29:07.512 - [1]: connected (2)
INFO 10:29:07.513 - [1]: send - hello (#0) (3)
INFO 10:29:07.628 - [1]: received - hello (#0) (4)
INFO 10:29:09.522 - [1]: disconnected - 1 message(s) received (5)
INFO 10:29:09.528 - all endpoints closed
-
Client connects to
ws://echo.websocket.org
-
The ID of the endpoint is shown in brackets. Each simulated endpoint has its own identifier.
-
Client endpoint sends first message to server.
-
Client endpoint received first message from server
-
WebSocket closed and client endpoint disconnected
To send two messages to the ws://192.168.56.201:8081/echo with three clients and delay of 500ms execute:
$ java -jar ws-simple-client-0.2.2-jar-with-dependencies.jar --url ws://192.168.56.201:8081/echo --endpoints 3 --messages 2 --delay 500
INFO 10:33:07.377 - Connect to URI: ws://192.168.56.201:8081/echo
INFO 10:33:08.426 - [1]: connected (1)
INFO 10:33:08.672 - [2]: connected
INFO 10:33:08.890 - [3]: connected (2)
INFO 10:33:08.890 - [1]: send - hello (#0)
INFO 10:33:08.896 - [2]: send - hello (#0)
INFO 10:33:08.897 - [3]: send - hello (#0)
INFO 10:33:09.039 - [2]: received - hello (#0)
INFO 10:33:09.048 - [3]: received - hello (#0)
INFO 10:33:09.048 - [1]: received - hello (#0)
INFO 10:33:09.400 - [1]: send - hello (#1)
INFO 10:33:09.401 - [2]: send - hello (#1)
INFO 10:33:09.402 - [3]: send - hello (#1)
INFO 10:33:09.516 - [3]: received - hello (#1)
INFO 10:33:09.516 - [2]: received - hello (#1)
INFO 10:33:09.517 - [1]: received - hello (#1)
INFO 10:33:10.906 - [1]: disconnected - 2 message(s) received
INFO 10:33:10.907 - [2]: disconnected - 2 message(s) received
INFO 10:33:10.908 - [3]: disconnected - 2 message(s) received
INFO 10:33:10.912 - all endpoints closed
-
First client endpoint connected to the server
-
Up to three endpoints are simulate with this call.
For installation just download the ws-simple-client-0.2.2-jar-with-dependencies.jar
file from the GitHub repository and execute it (see example below):
$ java -jar ws-simple-client-0.2.2-jar-with-dependencies.jar -h
Usage: ws-client-simple [options]
Options:
-h, --help
Show help screen.
--url
Target WebSocket endpoint
Default: ws://echo.websocket.org
--endpoints
Number of parallel client endpoints
Default: 1
--messages
Number of messages to be send to the server
Default: 1
--delay
Delay between sending messages (milliseconds)
Default: 1000
Please read Contributing for details on our code of conduct, and the process for submitting pull requests to us.