Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提供 HttpServer / WebSocketServer 绑定多端口的实现 #3

Closed
huangzhhui opened this issue Mar 22, 2018 · 3 comments
Closed

提供 HttpServer / WebSocketServer 绑定多端口的实现 #3

huangzhhui opened this issue Mar 22, 2018 · 3 comments
Labels
草案 draft

Comments

@huangzhhui
Copy link

目前无法实现一个服务暴露多个端口用于 HTTP/WS 服务,建议提供此功能用于满足一些工具型后台或后台的功能

@matyhtf matyhtf added the 草案 draft label Mar 22, 2018
@breath-co2
Copy link

一直就可以的吧

@huangzhhui
Copy link
Author

@breath-co2
HTTP/WebSocket 服务器是主服务器,无法直接通过 listen 添加端口监听 HTTP/WebSocket 协议服务
https://wiki.swoole.com/wiki/page/16.html
https://wiki.swoole.com/wiki/page/525.html

@breath-co2
Copy link

你需要加一个 open_websocket_protocol 参数(文档有相关参数说明),例如:

$port1 = $server->listen("127.0.0.1", 9501, SWOOLE_SOCK_TCP);
$port1->set([
    'open_websocket_protocol' => true,
]);

同理,还有 open_http_protocol open_http2_protocol 参数,另外需要注意的是,如果你是 new 了一个 http/websocket 的服务,又想监听普通的 tcp 端口,需要设置这些参数 false 才可以。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
草案 draft
Projects
None yet
Development

No branches or pull requests

3 participants