8000 WFNetworkTask作为client时是不是都是请求应答模式,请求应答后连接即断开 · Issue #1709 · sogou/workflow · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

WFNetworkTask作为client时是不是都是请求应答模式,请求应答后连接即断开 #1709

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

Open
love2014 opened this issue Apr 12, 2025 · 3 comments

Comments

@love2014
Copy link

WFNetworkTaskFactory的create_client_task函数创建的WFNetworkTask都是请求应答式的短连接吗,如何实现长连接?我试了下tutorial-10也是短连接

@Barenboim
Copy link
Contributor
Barenboim commented Apr 12, 2025

你好,我们tutorial-10的例子是长连接的。

首先,server端的默认连接保持时间是60秒。其次,client侧有一行:

task->set_keep_alive(30 * 1000);

这里吧请求完成之后连接保持时间设置为30秒。如果不调用set_keep_alive(),client任务默认就是短连接。

@Barenboim
Copy link
Contributor
7DE0

不过,这个例子确实是请求-应答模式的。你是希望长连接随时互相发消息吗?这个实现起来比较困难,而且有一些限制。内网的话建议在client端也打开一个server,互相请求最简单,可以认为是actor模式。

我们内置的redis subscriber实现了一个长连接通讯,但subscriber是一个客户端,服务端是redis server。

@love2014
Copy link
Author

不过,这个例子确实是请求-应答模式的。你是希望长连接随时互相发消息吗?这个实现起来比较困难,而且有一些限制。内网的话建议在client端也打开一个server,互相请求最简单,可以认为是actor模式。

我们内置的redis subscriber实现了一个长连接通讯,但subscriber是一个客户端,服务端是redis server。

好的好的,感谢耐心解答,我最近在学习workflow的代码,我再详细看看用例10,再次感谢!

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

No branches or pull requests

2 participants
0