websocket测试工具
http://coolaf.com/zh/tool/chattest
python3测试websocket代码
import asyncio import websockets async def server(websocket, path): while True: message = await websocket.recv() print(f"Received message: {message}") await websocket.send(f"Server received message: {message}") start_server = websockets.serve(server, "localhost", 8765) asyncio.get_event_loop().run_until_complete(start_server) asyncio.get_event_loop().run_forever()
nginx配置文件
server { listen 80; listen 443 ssl; server_name pcdev.tsmon.com; #ssl on; ssl_certificate /usr/local/ssl/pcdev.solomon.com/Nginx/pcdev.tsmon.crt; #注意域名填写正确 ssl_certificate_key /usr/local/ssl/pcdev.solomon.com/Nginx/pcdev.tsmon.key; #注意域名填写正确 ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDH:AESGCM:HIGH:!RC4:!DH:!MD5:!aNULL:!eNULL; ssl_prefer_server_ciphers on; #charset koi8-r; access_log /usr/share/nginx/html/srt-pc/dist/logs/access.log; location ^~ / { root /usr/share/nginx/html/srt-pc/dist/; index index.html; try_files $uri $uri/ /index.html; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location ~ .*\.(html)$ { add_header Cache-Control no-store; } location /api/ { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://127.0.0.1:8084/api/; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location /wss { proxy_pass http://127.0.0.1:8066; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /tsmon { proxy_pass http://127.0.0.1:8833; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } error_page 404 /404.html; error_log /usr/share/nginx/html/srt-pc/dist/logs/error.log; error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/sites/yourmall; } }