Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`firebase_admin.db.reference` leaks connections in a `CLOSE_WAIT` state

未关闭
#709 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
firebase, python
领域
database

调研方向

首先,使用 Python websocket 服务器重现该问题:创建一个 firebase_admin.db.reference,并在连接处理程序中调用 set。连接终止后使用 netstat 检查 CLOSE_WAIT 套接字。完成的标准是解释 reference 连接的生命周期,并解决报告的累积问题,或记录所需的 teardown 行为。

由索引模型根据 Issue 内容生成。

描述

api: database type: bug
Step 2: Describe your environment
  • Operating System version: OS X Ventura 13.4
  • Firebase SDK version: 6.2.0
  • Firebase Product: database
  • Python version: 3.11.2
  • Pip version: 23.1.2
Step 3: Describe the problem

I have a Python websocket application that creates a reference to RTDB via firebase_admin.db.reference, and writes to it via the set method. I create one reference per connection to my database. It appears that this reference does not necessarily get cleaned up, as I've noticed in my server that connections with a CLOSE_WAIT state are aggregating specifically with this RTDB update. More concerning is that the application appears to be receiving bytes of data at a consistent rate from this connection despite it being in a CLOSE_WAIT state.

What is the proper way to tear down a reference once I know I'm done with it? It seems like this is a bug from the firebase_admin python package as there don't be any instructions or indication that we need to tear down the reference.

Steps to reproduce:
  1. Create a Python websocket server with the websockets library
  2. Within the connection handler, instantiate a reference via firebase_admin.db.reference and write a value
  3. Approximately 1 minute after the connection terminates, use netstat to observe that the connection still exists in a CLOSE_WAIT state and that the application is receiving data from it.

Here's my netstat output

root@474683837e04:/app# netstat -ntuap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.11:38913        0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      1/python
tcp       25      0 172.24.0.3:34160        34.120.160.131:443      CLOSE_WAIT  1/python
tcp        1      0 172.24.0.3:58576        142.250.191.74:443      CLOSE_WAIT  1/python
tcp6       0      0 :::8080                 :::*                    LISTEN      1/python
udp        0      0 127.0.0.11:54888        0.0.0.0:*                           -

Using connections with all of the reference related code commented out and then netstat'ing after shows that this issue does not appeare.

主要语言
Python
星标
1.2k
派生
359
平均合并
5 天 6 分钟
30 天内合并 PR
2

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/firebase-admin-python 的其他 Issue

查看 firebase/firebase-admin-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。