为什么有这么多连接到 ESTABLISHED 和 TIME_WAIT 的同一个模拟器端口

why so many connection to same Emulator port with ESTABLISHED and TIME_WAIT

在使用 Android Studio

时,我正在努力寻找一些方法来处理项目中的两个永久性错误
Emulator: emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037

Emulator: socketTcpLoopbackClientFor: error: fd 56668 above FD_SETSIZE (32768)

无论我用哪个Android/API版本,这两个错误都不会消失。我发现连接到此类端口的模拟器连接数有点奇怪。也许它是设计成那样工作的,或者也许我搞砸了一些东西,我找不到什么(我卸载并重新安装 Android Studio 从头开始​​,同样的问题仍然存在)

这是事件日志

01/06/2020
00:08   Gradle sync started
00:08   * daemon not running; starting now at tcp:5037
00:08   * daemon started successfully
00:08   Gradle sync finished in 2 s 418 ms (from cached state)
00:08   Executing tasks: [:app:assembleDebug] in project C:\WSs\FireStoreDemos\AppFirestore
00:08   Emulator: socketTcpLoopbackClientFor: error: fd 56296 above FD_SETSIZE (32768)
00:08   Emulator: socketTcpLoopbackClientFor: error: fd 56296 above FD_SETSIZE (32768)
00:08   Emulator: emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037
00:08   Emulator: socketTcpLoopbackClientFor: error: fd 56668 above FD_SETSIZE (32768)
00:08   Emulator: socketTcpLoopbackClientFor: error: fd 56668 above FD_SETSIZE (32768)
00:08   Emulator: socketTcpLoopbackClientFor: error: fd 56928 above FD_SETSIZE (32768)
00:08   Emulator: socketTcpLoopbackClientFor: error: fd 56928 above FD_SETSIZE (32768)
00:08   Gradle build finished in 19 s 659 ms
00:08   Install successfully finished in 584 ms.: App restart successful without requiring a re-install.

在我 运行 运行应用程序时,错误 "Emulator: socketTcpLoopbackClientFor: error: fd 60252 above FD_SETSIZE (32768)" 每分钟都会不断弹出。

这就是我认为奇怪的地方

C:\Users>netstat -ano | findstr "5037"
  TCP    127.0.0.1:5037         0.0.0.0:0              LISTENING       11880
  TCP    127.0.0.1:5037         127.0.0.1:54602        ESTABLISHED     11880
  TCP    127.0.0.1:5037         127.0.0.1:54631        ESTABLISHED     11880
  TCP    127.0.0.1:5037         127.0.0.1:54643        ESTABLISHED     11880
  TCP    127.0.0.1:5037         127.0.0.1:54647        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54648        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54649        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54650        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54662        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54663        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54665        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54666        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54667        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54668        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54669        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54670        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54671        ESTABLISHED     11880
  TCP    127.0.0.1:5037         127.0.0.1:54672        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54673        ESTABLISHED     11880
  TCP    127.0.0.1:5037         127.0.0.1:54674        TIME_WAIT       0
  TCP    127.0.0.1:54602        127.0.0.1:5037         ESTABLISHED     348
  TCP    127.0.0.1:54631        127.0.0.1:5037         ESTABLISHED     5224
  TCP    127.0.0.1:54634        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:54636        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:54639        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:54641        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:54643        127.0.0.1:5037         ESTABLISHED     348
  TCP    127.0.0.1:54671        127.0.0.1:5037         ESTABLISHED     348
  TCP    127.0.0.1:54673        127.0.0.1:5037         ESTABLISHED     348

C:\Users>

所以我的直截了当的问题是:为什么这么多 ESTABLISHED 和 TIME_WAIT 连接到 5037?

一些有用的评论可能会帮助我继续前进:Android Studio 真的需要在启动期间和我 run/debug 应用程序之前使用这样的端口吗?任何只在调试时启动守护进程的技巧(作为一个糟糕的类比,我们不会在 Spring Boot 中编码时一直保持 TomCat 启动 运行ning)。我不明白为什么我在启动 Android Studio 后立即收到此消息 "daemon not running; starting now at tcp:5037",因为我还没有通过 运行 或调试开始有效地使用模拟器。

作为我迄今为止找到的唯一合理答案,我部分基于other proposal

回答我自己的问题

这似乎是模拟器多核 CPU 的一个问题。因此,只需在 Avd Manager -> Select 模拟器 -> 编辑 -> 高级设置 -> 多核 CPU -> 取消选中此选项

后取消选中多核 CPU

也许以后有人可以在这里添加更好的解释

Emulator: socketTcpLoopbackClientFor: error: fd 56668 above FD_SETSIZE (32768)

我有 AMD 显卡,但遇到了同样的错误。 ^^ 我通过转到 AVD Manager - Select 模拟器 - 编辑 - 模拟性能,图形来修复它:选择 -> 软件。