1. 用wscat
点击(此处)折叠或打开
- #安装
- npm install -g wscat
- wscat -c ws://127.0.0.1:8080/
-
#测试成功会显示如下:
Connected (press CTRL+C to quit)
2. python3下用socketio脚本来测试
点击(此处)折叠或打开
-
import time
-
import socketio
-
-
sio = socketio.Client(logger=True, engineio_logger=True)
-
-
start_time = None
-
@sio.event
-
def connect():
-
global start_time
-
latency = time.time() - start_time
-
print("I'm connected!",latency)
-
-
@sio.event
-
def connect_error(data):
-
global start_time
-
latency = time.time() - start_time
-
print("The connection failed!", latency)
-
-
@sio.event
-
def disconnect():
-
global start_time
-
latency = time.time() - start_time
-
print("I'm disconnected!", latency)
-
-
if __name__ == '__main__':
-
start_time = time.time()
-
try:
-
sio.connect('ws://127.0.0.1:8080/')
-
sio.wait()
-
print("run over")
-
except Exception as e:
-
latency = time.time() - start_time
-
print("latency:", latency)
- print("error: get excption:"+repr(e))