dfinity / dfinity/sdk

dfx 端口不一致导致 ping 失败的问题

Open
#4,249 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
Dominant language
Rust
Stars
204
Forks
98
PR merge metrics
No merged PRs in 30d

Description

dfx 端口不一致导致 ping 失败的问题

问题描述

使用 dfx 0.26.1 版本时遇到 replica 端口不一致的问题,导致无法正常连接本地节点。

复现步骤

  1. 安装并使用 dfx 0.26.1 版本
  2. 执行启动命令:
    dfx start --clean --replica
    
  3. 得到成功启动提示:
    Running dfx start for version 0.26.1
    Using the default configuration for the local shared network.
    Replica API running on 127.0.0.1:4943. You must open a new terminal to continue developing. If you'd prefer to stop, quit with 'Ctrl-C'.
    
  4. 在新终端中执行 ping 命令:
    dfx ping
    

错误信息

Error: Failed while waiting for agent status.
Caused by: The replica returned an HTTP Error: Http Error: status 502 Bad Gateway, content type "text/plain; charset=utf-8", content: ConnectionFailure: HTTP request failed: error sending request for url (http://localhost:50882/api/v2/status)

问题分析

启动提示显示 replica API 运行在 127.0.0.1:4943,但 dfx ping 却尝试连接到 localhost:63009,导致端口不一致,无法正常通信。

系统环境

  • dfx 版本: 0.26.1
  • 操作系统: [请补充您的操作系统信息]
  • 其他相关环境信息: [如有其他相关信息请补充]

期望的行为

dfx ping 应该使用与 dfx start 输出中相同的端口(4943)进行通信,或者提供明确的配置方法来解决这一不一致问题。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the reported dfx start --clean --replica and dfx ping commands as the entry point, then trace how each command selects the replica API port. Reproduce the 0.26.1 behavior and compare the advertised 4943 endpoint with the endpoint used by ping. Done means ping communicates with the started local replica or the configuration mismatch is clearly reported.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.