Skip to content

[C#]: #3608

Description

@yzsyzdy

检查项 / Checklist

  • 我已在 Issues 页面 中搜索,确认了这一 Bug 未被提交过 / I have searched the Issues page and confirmed that this bug has not been reported yet.
  • 我确认只是全部选中而没有仔细确认就直接提交了这个 Issue,并且同意这个 Issue 可以直接被关闭 / I confirm that I checked all boxes without carefully reading them, and agree that this issue may be closed directly.
  • 我确认正在使用当前更新分支的最新版 PCL CE,若不是,此 Issue 可能会被直接关闭(更新方式:启动器 设置-关于-软件更新 检查更新,或在 Releases 页面下载) / I confirm that I am using the latest PCL CE version on the current update channel. If not, this issue may be closed directly. To update, check for updates in Settings → About → Updates, or download the latest version from the Releases page.
  • 我确认会详细描述我所遇到的问题,并附上日志和截图,而不是随便填点东西敷衍了事 / I will describe the problem in detail, attach logs and screenshots, and avoid submitting vague or incomplete information.

描述 / Description

[Bug] 查询无人在线的服务器时状态获取失败:无法连接: Value cannot be null. (Parameter 'source')

重现步骤 / Steps to Reproduce

[Bug] 查询无人在线的服务器时状态获取失败:无法连接: Value cannot be null. (Parameter 'source')

问题描述

在服务器列表中刷新一个「当前无人在线」的服务器时,状态查询失败,界面显示红色错误:

无法连接: Value cannot be null. (Parameter 'source')

但实际的网络连接是成功的:同一条结果卡片里,服务器的 MOTD、在线人数、延迟都已正常渲染出来。
这说明请求已成功返回、响应也已解析出部分字段,异常发生在结果处理阶段,而不是网络阶段
(界面上的「无法连接」提示容易误导,实际并非连接失败)。

复现时的截图表现为:

  • 红色错误:无法连接: Value cannot be null. (Parameter 'source')
  • 同时正常显示:MOTD(带颜色格式)、0 / 200 在线人数、100ms 延迟
  • 服务器图标也正常加载

复现步骤

  1. 在 PCL CE 的服务器列表中添加服务器地址(本次复现使用 mcbreeze.space:15000)
  2. 确认该服务器当前在线玩家数为 0
  3. 刷新 / 重新查询该服务器状态
  4. 观察查询结果

实际结果

显示错误提示:

无法连接: Value cannot be null. (Parameter 'source')

同一结果卡片中,MOTD(格式化文本)、0 / 200 人数、100ms 延迟均正常显示。

期望结果

正常显示服务器状态:0 / 200 在线人数、MOTD、延迟,不出现错误提示。

推测原因

Minecraft 服务器的 status 响应中,players.sample(在线玩家列表)在无玩家在线时会缺省
或为 null。如果解析代码对该字段直接进行 LINQ 枚举(例如
response.Players.Sample.Select(...) 或 .Where(...))而没有做判空处理,就会抛出
ArgumentNullException,其消息正是 Value cannot be null. (Parameter 'source')
(source 是 Enumerable 扩展方法的参数名)。

验证方式

  • 目标服务器 0 人在线 → 复现报错
  • 目标服务器有至少 1 人在线 → 查询正常,无报错

以此可确认问题与 sample 字段为空直接相关。

与已有 Issue 的关系

已检索 Issues(关键词:Value cannot be null、Parameter 'source'、服务器状态),未被提交过。

需要与 #3522([C#]:服务器状态,Open)区分:#3522 日志中的错误为
System.IO.EndOfStreamException: 服务器在返回完整状态数据包前提前断开连接,属于响应被截断 /
连接提前关闭;本 Issue 的响应是完整收到的(MOTD、人数、延迟均正常显示)后才在解析阶段
抛出 ArgumentNullException,且仅在该服务器 0 人在线时复现。两者并非同一问题。

环境信息

项目 内容
PCL CE 版本 <填写版本号>
操作系统 Windows 11(10.0.26200)
目标服务器 Minecraft Java 26.2(Fabric,离线模式,经 FRP 穿透访问)
对照测试 同一服务器使用其他客户端与状态查询工具均可正常获取状态,说明服务端响应本身正常

日志

启动器日志见附件

日志与附件 / Logs & Attachments

PCL_CE_Logs_20260810161219.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    👌 完成相关问题已修复或功能已实现,计划在下次版本更新时正式上线

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions