You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub Actions中依赖服务器的XUnit测试连接失败问题

GitHub Actions中CoreServer依赖测试连接失败问题

我在GitHub Actions中运行依赖CoreServer.exe的XUnit测试,参考相关教程配置后仍无法正常工作。已在本地“防火墙和网络安全”的“高级设置”中添加端口3333的入站和出站允许规则,但测试时始终出现如下错误:

Connect to command client exception: No connection could be made because the target machine actively refused it 127.0.0.1:3333
Connect Exception: No connection could be made because the target machine actively refused it 127.0.0.1:3333.

工作流会陷入无限循环,直到手动取消。

附上完整的GitHub Actions工作流文件,核心步骤为后台启动CoreServer.exe后运行FluidTransferTests:

name: Test unit tests CI

on:
  push:
    branches: [ "dev" ]
  pull_request:
    branches: [ "dev" ]

jobs:
  build:
    runs-on: windows-2022

    steps:
    - uses: actions/checkout@v3

    - name: setup Msbuild
      uses: microsoft/setup-msbuild@v1.3.1

    - name: Setup NuGet
      uses: NuGet/setup-nuget@v1.2.0

    - name: Setup VSTest Console
      uses: darenm/Setup-VSTest@v1.2

    #Restore NuGet packages for CoreServer and build the Solution.
    - name: Restore NuGet packages for CoreServer
      run: nuget restore ./Core/CoreServer/CoreServer.sln

    - name: Build the CoreServer solution
      run: msbuild ./Core/CoreServer/CoreServer.sln /p:platform="Any CPU" /p:configuration="Release"

    #Restore NuGet packages for CoreClient and build the Solution.
    - name: Restore NuGet packages for CoreClient
      run: nuget restore ./Core/CoreServer/CoreClient.sln

    - name: Build the CoreClient solution
      run: msbuild ./Core/CoreServer/CoreClient.sln /p:platform="Any CPU" /p:configuration="Release"

    #Restore NuGet packages for EchoNETServer and build the Solution.
    - name: Restore NuGet packages for EchoNETServer
      run: nuget restore ./EchoNET/EchoNETServer.sln

    - name: Build the EchoNETServer solution
      run: msbuild ./EchoNET/EchoNETServer.sln /p:platform="Any CPU" /p:configuration="Release"

    #Restore NuGet packages for EchoNETClient and build the Solution.
    - name: Restore NuGet packages for EchoNETClient
      run: nuget restore ./EchoNET/EchoNETClient.sln

    - name: Build the EchoNETClient solution
      run: msbuild ./EchoNET/EchoNETClient.sln /p:platform="Any CPU" /p:configuration="Release"

    #Restore NuGet packages for EchoServer and build the Solution.
    - name: Restore NuGet packages for EchoServer
      run: nuget restore ./Echo/EchoServer.sln

    - name: Build the EchoServer solution
      run: msbuild ./Echo/EchoServer.sln /p:platform="Any CPU" /p:configuration="Release"

    #Wait for the actions to complete before starting
    - name: Delay for the process to complete
      run: sleep 7

    #Start CoreServer.exe in background and run the FluidtransferTests
    - name: Start CoreServer.exe in the background and run the FluidTransferTests
      run: |
         ./Core/CoreServer/Server/CoreServer/Bin/Debug/CoreServer.exe -c -s &
         vstest.console.exe ./Pico/Medman/FluidTransferTests/bin/Release/net481/FluidTransferTests.dll

测试输出显示服务器后台任务处于Running状态,但测试无法连接端口3333;添加curl验证步骤后,得到错误:
curl: (7) Failed to connect to localhost port 3333 after 2225 ms: Couldn't connect to server

本地运行CoreServer时,netstat -a显示端口3333处于监听状态。

内容的提问来源于stack exchange,提问作者nikhil

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 12:08:17