每当后台服务器部署一个websocket服务需要做测试,测试推流可行性时前后端调试不太方便,可以直接通过命令行工具调试:安装wscat即可。
1,首先安装nodejs
Nodejs安装说明
2,安装wscat
npm install -g wscat (回车创建全局wscat工具)
3,创建websocket服务端
wscat -l 8888
4,创建web socket客户端文章来源:https://www.toymoban.com/news/detail-774068.html
wscat -c ws://localhost:8888
5,wscat参数说明文章来源地址https://www.toymoban.com/news/detail-774068.html
Usage: wscat [options] (--listen <port> | --connect <url>)
Options:
-V, --version output the version number
--auth <username:password> add basic HTTP authentication header (--connect only)
--ca <ca> specify a Certificate Authority (--connect only)
--cert <cert> specify a Client SSL Certificate (--connect only)
--host <host> optional host
--key <key> specify a Client SSL Certificate's key (--connect only)
--max-redirects [num] maximum number of redirects allowed (--connect only) (default: 10)
--no-color run without color
--passphrase [passphrase] specify a Client SSL Certificate Key's passphrase (--connect only). If you don't
provide a value, it will be prompted for
--proxy <[protocol://]host[:port]> connect via a proxy. Proxy must support CONNECT method
--slash enable slash commands for control frames (/ping, /pong, /close [code [, reason]])
-c, --connect <url> connect to a WebSocket server
-H, --header <header:value> set an HTTP header. Repeat to set multiple (--connect only) (default: [])
-L, --location follow redirects (--connect only)
-l, --listen <port> listen on port
-n, --no-check do not check for unauthorized certificates
-o, --origin <origin> optional origin
-p, --protocol <version> optional protocol version
-P, --show-ping-pong print a notification when a ping or pong is received
-s, --subprotocol <protocol> optional subprotocol (default: [])
-w, --wait <seconds> wait given seconds after executing command
-x, --execute <command> execute command after connecting
-h, --help display help for command
到了这里,关于【WebSocket】工具wscat安装和使用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!