node.js - 如何关闭 Node.js http.createClient 的连接?

标签 node.js http connection

有没有类似的东西

remote_client.close()

request.close()

用于关闭 http.createClient 连接?

似乎在某些情况下,在发出“response”事件并妥善处理后,套接字连接仍然卡在那里。

最佳答案

升级到最新版本的 node.js (0.4.8)。

创建客户端的语法已经改变。你现在有

http.request

返回 ClientRequest你可以.end它给你一个 ClientResponse在回调中。

ClientReponse 只是一个 Readable Stream你可以.destroy一个流

关于node.js - 如何关闭 Node.js http.createClient 的连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6155830/

相关文章:

python - 当我在一个函数中声明多个连接时,如何确保连接关闭?

javascript - Node js 下载与文件流

javascript - 如何在 Passport/Node js 中找出 last_login_date

node.js - 尽管 ~/.bashrc 和 ~/.bash_profile 中都存在 "nvm"变量,但在新命令行窗口/选项卡中无法识别 "NVM_DIR"命令

http - 如果删除仅部分成功,要使用正确的 http 状态代码吗?

github - 克隆时git连接超时

javascript - Express.js 路由没有意义

c# - GetRequestStream() 返回 WebException 超时......但仅在某些机器上

java - 如何像在 Google Oauth Playground 中一样向 Google API 发送 HTTP 请求?

php - 在 PHP 中,什么对应于 MySQLi 中的 mysql.connect_timeout?