1 Star 0 Fork 5

yirenji / thinkphp-swoole3-websocket

Gitee — Enterprise-level DevOps R&D management platform
Join Gitee
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

##thinkphp6.0+thinkphp-swoole3的websocket实现demo

运行环境要求PHP7.1+

swoole4.5+

测试地址: https://域名/static/web/ws.html

wss连接地址: wss://域名/ws?token=3 token留作鉴权使用,自行实现.demo会将token作为unique使用

命令格式:

  • methods执行{"cmd":"sys"}
  • 单/多methods执行{"cmd":"sys.ping"} / {"cmd":"sys.ping.syncMsg"}

实现了配置化task任务,参照demo样例配置实现即可.

注意:在服务启动时(SwooleBoot.php)会对task.php与websocket.php的class/methods进行检查!若检查失败则停止启动!

go版本实现地址 https://gitee.com/tsbjt/goframe-websocket

nginx配置如下

server {
	listen       443;
	
	ssl on;
	ssl_certificate 证书.pem;
	ssl_certificate_key 证书.key;
	ssl_session_timeout 5m;
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_prefer_server_ciphers on;
        server_name  域名;
	location / {
		proxy_http_version 1.1;
        proxy_set_header Connection "keep-alive";
        proxy_set_header X-Real-IP $remote_addr;
        if (!-e $request_filename) {
             proxy_pass http://127.0.0.1:9501;
        }
	}
        location /ws {	
		proxy_connect_timeout 60;
        proxy_send_timeout 60;
        proxy_read_timeout 60;
        proxy_buffer_size 256k;
        proxy_buffers 4 256k;
        proxy_busy_buffers_size 256k;
        proxy_temp_file_write_size 256k;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_404;
        proxy_max_temp_file_size 128m;
        proxy_pass http://127.0.0.1:9501;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";	
	 }
}

Repository Comments ( 0 )

Sign in for post a comment

About

tp6+think-swoole3扩展实现的基础websocket通讯结构.对事件行为配置化,高度可控自由.只需添加配置参数与编写逻辑即可. expand collapse
Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more
PHP
1
https://gitee.com/thinkphpbox/thinkphp-swoole3-websocket.git
git@gitee.com:thinkphpbox/thinkphp-swoole3-websocket.git
thinkphpbox
thinkphp-swoole3-websocket
thinkphp-swoole3-websocket
master

Search

181749 a2d7925e 1850385 181749 9f8568a7 1850385