• 推荐一个websocket测试工具:wscat


    开发WebSocket程序时,都会需要一个测试环境,用来调试WebSocket的连接和收发消息。

    这里推荐一个基于nodejs环境的websocket测试工具:wscat(WebSocket Cat)

    官网:https://github.com/websockets/wscat

    一、安装(windows环境)

    1、首先要安装nodejs:http://nodejs.cn/download/

    2、在cmd中使用全局安装wscat

    cnpm install -g wscat

    二、作为服务端使用

    打开命令窗口,输入命令:wscat -l 8888 (注意是字母L),即可在本地8888端口启动websocket服务监听,此时就已经在你本机中启动了一个websocket服务端程序了。

    wscat -l 8888

    三、作为客户端使用

    打开一个新的命令窗口,输入命令:wscat -c ws://localhost:8888,来连接到刚刚创建的websocket服务端。

    wscat -c ws://localhost:8888

    四、命令参数说明

    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
  • 相关阅读:
    Java High Level REST Client 中文API(仅供参考)
    3.2_springBoot2.1.x检索之JestClient操作ElasticSearch
    3.1_springboot2.x检索之elasticsearch安装&快速入门
    2.2_springboot2.x消息RabbitMQ整合&amqpAdmin管理组件的使用
    2.1_springboot2.x消息介绍&RabbitMQ运行机制
    1.2_springboot2.x中redis缓存&原理介绍
    1.1_springboot2.x与缓存原理介绍&使用缓存
    JavaWeb-----Get请求和Post请求
    Java基础(basis)-----TCP通信
    Java基础(basis)-----泛型详解
  • 原文地址:https://www.cnblogs.com/netWild/p/16226742.html
Copyright © 2020-2023  润新知