To get hold of the tool at the moment you are going to have to do a little bit of work with svn and maven. So you need to check out the head of
https://svn.java.net/svn/tyrus~source-code-repository/trunk
and then perform a mvn package
on the etc/client-cli sub project. Depending on the state of the maven repository you might need to do a mvn install -DskipTests=true
on the root project first.You can now find the executable jar in
.../tyrus/ext/client-cli/target
called something like tyrus-client-cli....jar
. This has been shaded so it contains all of the required deps to run. Simples.The tool currently allows you to send text and ping messages. It can receive binary messages but it just displays the hex values of up to the first 1024 bytes.
So you can either pass in the ws:// URL as the single command line argument or you can connect using the open command once the tool is running. Here are some very simple commands along with a response from a simple echo web socket service.
gdavison@gbr10460 ~]$ java -jar ~/software/tyrus-client-cli-1.0-SNAPSHOT.jar ws://localhost:7101/Project1/echo # Connecting to ws://localhost:7101/Project1/echo... # Connected in session 689607b4-7bd8-465a-8d84-e0dca54fa3e8 session 6896...a3e8> session 6896...a3e8> send Hello! # text-message: Message out Hello! session 6896...a3e8> send # End multiline message with . on own line send...> Some send...> Long send...> Message send...> . # text-message: Message out Some # Long # Message # session 6896...a3e8> close # closed: CloseReason[1000,no reason given] # Session closed tyrus-client> quit gdavison@gbr10460 ~]$ java -jar ~/software/tyrus-client-cli-1.0-SNAPSHOT.jar tyrus-client> tyrus-client> open ws://localhost:7101/Project1/echo # Connecting to ws://localhost:7101/Project1/echo... # Connected in session 59e501a9-a793-4321-ba6a-1c73c13bd822 session 59e5...d822> session 59e5...d822> ping # pong-message session 59e5...d822> help # open uri : open a connection to the web socket uri close : close a currently open web socket session send message : send a text message send : send a multiline text message teminated with a . ping : send a ping message quit | exit : exit this tool help : display this message session 59e5...d822>
I can see this being very helpful when trying to debug a web socket service and you want to remove the web browser out of the equation. It is implemented using JLine2 so it behaves like a native command line tool so is pleasant to use.
No comments:
Post a Comment