http端点不与elsa err_connection_refuse使用

发布于 01-20 08:05 字数 5207 浏览 3 评论 0原文

我尝试在.NET标准6.0中创建Web应用程序,并为HTTP Endpoint请求添加了一个简单的工作流程&回答。 但是服务器URL返回err_connection_refused用URL(https:// localhost:5001/data)。 我添加了我的源代码详细信息,请让我知道是否需要了解该问题。

我正在使用.NET Standard 6.0和Elsa 2.6

Program.cs

using Elsa;
using Elsa.Persistence.EntityFramework.Core.Extensions;
using Elsa.Persistence.EntityFramework.Sqlite;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = WebApplication.CreateBuilder(args);
var elsaSection = builder.Configuration.GetSection("Elsa");

// Elsa services.
builder.Services
    .AddElsa(elsa => elsa
        .UseEntityFrameworkPersistence(ef => ef.UseSqlite())
        .AddConsoleActivities()
        .AddHttpActivities(elsaSection.GetSection("Server").Bind)
        .AddQuartzTemporalActivities()
        .AddWorkflowsFrom<Startup>()
    );

// Elsa API endpoints.
builder.Services.AddElsaApiEndpoints();
builder.Services.AddCors(cors => cors.AddDefaultPolicy(policy => policy
    .AllowAnyHeader()
    .AllowAnyMethod()
    .AllowAnyOrigin()
    .WithExposedHeaders("Content-Disposition"))
);
// For Dashboard.
builder.Services.AddRazorPages();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
}

app
    .UseStaticFiles() 
    .UseCors()
    .UseHttpActivities()
    .UseRouting()
    .UseEndpoints(endpoints =>
    {
        // Elsa API Endpoints are implemented as regular ASP.NET Core API controllers.
        endpoints.MapControllers();

        // For Dashboard.
        endpoints.MapFallbackToPage("/_Host");
    });


app.Run();

AppSetting.json

  "Elsa": {
    "Server": {
      "BaseUrl": "https://localhost:5001"
    }
  }
}
--------------------------------------------------------------
Exported workflow details

{
  "$id": "1",
  "definitionId": "77bbdbc2d83e402082292c26a054cdce",
  "versionId": "2f40a957f6474d9f9a6291116407bda3",
  "name": "data",
  "displayName": "data",
  "version": 1,
  "variables": {
    "$id": "2",
    "data": {}
  },
  "customAttributes": {
    "$id": "3",
    "data": {}
  },
  "isSingleton": false,
  "persistenceBehavior": "WorkflowBurst",
  "deleteCompletedInstances": false,
  "isPublished": true,
  "isLatest": true,
  "activities": [
    {
      "$id": "4",
      "activityId": "e7685474-cbb7-44af-b15c-72d68897f537",
      "type": "HttpEndpoint",
      "displayName": "HTTP Endpoint",
      "persistWorkflow": false,
      "loadWorkflowContext": false,
      "saveWorkflowContext": false,
      "properties": [
        {
          "$id": "5",
          "name": "Path",
          "expressions": {
            "$id": "6",
            "Literal": "/data"
          }
        },
        {
          "$id": "7",
          "name": "Methods",
          "expressions": {
            "$id": "8",
            "Json": "[\"GET\"]"
          }
        },
        {
          "$id": "9",
          "name": "ReadContent",
          "expressions": {
            "$id": "10"
          }
        },
        {
          "$id": "11",
          "name": "TargetType",
          "expressions": {
            "$id": "12"
          }
        },
        {
          "$id": "13",
          "name": "Schema",
          "syntax": "Literal",
          "expressions": {
            "$id": "14",
            "Literal": ""
          }
        },
        {
          "$id": "15",
          "name": "Authorize",
          "expressions": {
            "$id": "16"
          }
        },
        {
          "$id": "17",
          "name": "Policy",
          "expressions": {
            "$id": "18"
          }
        }
      ],
      "propertyStorageProviders": {}
    },
    {
      "$id": "19",
      "activityId": "e447ad59-8482-43ed-958d-2f044b6ac672",
      "type": "WriteHttpResponse",
      "displayName": "HTTP Response",
      "persistWorkflow": false,
      "loadWorkflowContext": false,
      "saveWorkflowContext": false,
      "properties": [
        {
          "$id": "20",
          "name": "Content",
          "expressions": {
            "$id": "21"
          }
        },
        {
          "$id": "22",
          "name": "ContentType",
          "expressions": {
            "$id": "23"
          }
        },
        {
          "$id": "24",
          "name": "StatusCode",
          "expressions": {
            "$id": "25",
            "Literal": "OK"
          }
        },
        {
          "$id": "26",
          "name": "CharSet",
          "expressions": {
            "$id": "27",
            "Literal": "utf-8"
          }
        },
        {
          "$id": "28",
          "name": "ResponseHeaders",
          "expressions": {
            "$id": "29",
            "Literal": "data"
          }
        }
      ],
      "propertyStorageProviders": {}
    }
  ],
  "connections": [
    {
      "$id": "30",
      "sourceActivityId": "e7685474-cbb7-44af-b15c-72d68897f537",
      "targetActivityId": "e447ad59-8482-43ed-958d-2f044b6ac672",
      "outcome": "Done"
    }
  ],
  "id": "2f40a957f6474d9f9a6291116407bda3"
}````

Thanks in advance.



I tried creating a web app in .Net standard 6.0 and added a simple workflow for HTTP Endpoint requests & responses.
but the server URL returning ERR_CONNECTION_REFUSED with the URL(https://localhost:5001/data).
I have added my source code details, Please let me know if anything else required for understanding the issue.

I am using .Net Standard 6.0 and Elsa 2.6

Program.cs

using Elsa;
using Elsa.Persistence.EntityFramework.Core.Extensions;
using Elsa.Persistence.EntityFramework.Sqlite;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = WebApplication.CreateBuilder(args);
var elsaSection = builder.Configuration.GetSection("Elsa");

// Elsa services.
builder.Services
    .AddElsa(elsa => elsa
        .UseEntityFrameworkPersistence(ef => ef.UseSqlite())
        .AddConsoleActivities()
        .AddHttpActivities(elsaSection.GetSection("Server").Bind)
        .AddQuartzTemporalActivities()
        .AddWorkflowsFrom<Startup>()
    );

// Elsa API endpoints.
builder.Services.AddElsaApiEndpoints();
builder.Services.AddCors(cors => cors.AddDefaultPolicy(policy => policy
    .AllowAnyHeader()
    .AllowAnyMethod()
    .AllowAnyOrigin()
    .WithExposedHeaders("Content-Disposition"))
);
// For Dashboard.
builder.Services.AddRazorPages();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
}

app
    .UseStaticFiles() 
    .UseCors()
    .UseHttpActivities()
    .UseRouting()
    .UseEndpoints(endpoints =>
    {
        // Elsa API Endpoints are implemented as regular ASP.NET Core API controllers.
        endpoints.MapControllers();

        // For Dashboard.
        endpoints.MapFallbackToPage("/_Host");
    });


app.Run();

Appsetting.json

  "Elsa": {
    "Server": {
      "BaseUrl": "https://localhost:5001"
    }
  }
}
--------------------------------------------------------------
Exported workflow details

{
  "$id": "1",
  "definitionId": "77bbdbc2d83e402082292c26a054cdce",
  "versionId": "2f40a957f6474d9f9a6291116407bda3",
  "name": "data",
  "displayName": "data",
  "version": 1,
  "variables": {
    "$id": "2",
    "data": {}
  },
  "customAttributes": {
    "$id": "3",
    "data": {}
  },
  "isSingleton": false,
  "persistenceBehavior": "WorkflowBurst",
  "deleteCompletedInstances": false,
  "isPublished": true,
  "isLatest": true,
  "activities": [
    {
      "$id": "4",
      "activityId": "e7685474-cbb7-44af-b15c-72d68897f537",
      "type": "HttpEndpoint",
      "displayName": "HTTP Endpoint",
      "persistWorkflow": false,
      "loadWorkflowContext": false,
      "saveWorkflowContext": false,
      "properties": [
        {
          "$id": "5",
          "name": "Path",
          "expressions": {
            "$id": "6",
            "Literal": "/data"
          }
        },
        {
          "$id": "7",
          "name": "Methods",
          "expressions": {
            "$id": "8",
            "Json": "[\"GET\"]"
          }
        },
        {
          "$id": "9",
          "name": "ReadContent",
          "expressions": {
            "$id": "10"
          }
        },
        {
          "$id": "11",
          "name": "TargetType",
          "expressions": {
            "$id": "12"
          }
        },
        {
          "$id": "13",
          "name": "Schema",
          "syntax": "Literal",
          "expressions": {
            "$id": "14",
            "Literal": ""
          }
        },
        {
          "$id": "15",
          "name": "Authorize",
          "expressions": {
            "$id": "16"
          }
        },
        {
          "$id": "17",
          "name": "Policy",
          "expressions": {
            "$id": "18"
          }
        }
      ],
      "propertyStorageProviders": {}
    },
    {
      "$id": "19",
      "activityId": "e447ad59-8482-43ed-958d-2f044b6ac672",
      "type": "WriteHttpResponse",
      "displayName": "HTTP Response",
      "persistWorkflow": false,
      "loadWorkflowContext": false,
      "saveWorkflowContext": false,
      "properties": [
        {
          "$id": "20",
          "name": "Content",
          "expressions": {
            "$id": "21"
          }
        },
        {
          "$id": "22",
          "name": "ContentType",
          "expressions": {
            "$id": "23"
          }
        },
        {
          "$id": "24",
          "name": "StatusCode",
          "expressions": {
            "$id": "25",
            "Literal": "OK"
          }
        },
        {
          "$id": "26",
          "name": "CharSet",
          "expressions": {
            "$id": "27",
            "Literal": "utf-8"
          }
        },
        {
          "$id": "28",
          "name": "ResponseHeaders",
          "expressions": {
            "$id": "29",
            "Literal": "data"
          }
        }
      ],
      "propertyStorageProviders": {}
    }
  ],
  "connections": [
    {
      "$id": "30",
      "sourceActivityId": "e7685474-cbb7-44af-b15c-72d68897f537",
      "targetActivityId": "e447ad59-8482-43ed-958d-2f044b6ac672",
      "outcome": "Done"
    }
  ],
  "id": "2f40a957f6474d9f9a6291116407bda3"
}````

Thanks in advance.



如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

2025-01-27 08:05:15

当您想要调用 HTTP 端点时,您需要使用与托管 Elsa 的端口相同的端口。

例如,如果您有一个 HTTP Endpoint 活动,配置了 /start 作为其路径,并且您的 Web 应用托管在 https://localhost:7095/,那么您需要发出请求 https://localhost:7095/start

image

注意

可以配置用于侦听子路径的 HTTP 端点中间件(建议中间件不要尝试匹配每个和针对工作流程的每个请求)。如果是这种情况,请确保也包含此路径。

例如,如果您执行了以下操作:

elsa.AddHttpActivities(options => options.BasePath = "/workflows");

则 HTTP 端点的路径为:https://localhost:7095/workflows/start

When you want to invoke an HTTP endpoint, you need to use the same port as the one that is hosting Elsa.

For example, if you have an HTTP Endpoint activity configured with /start as its path, and your web app is hosted at https://localhost:7095/, then you need to make a request https://localhost:7095/start

image

Note

it is possible to configure the HTTP Endpoint middleware to listen on a subpath (which is recommended as to have the middleware not try and match each and every requests against a workflow). If this is the case, make sure to include this path as well.

For example, if you did something like this:

elsa.AddHttpActivities(options => options.BasePath = "/workflows");

Then the path to your HTTP Endpoint is: https://localhost:7095/workflows/start

揽月2025-01-27 08:05:15

ERR_CONNECTION_REFUSED 在端口 5001 中给我们带来的问题是,当我们遵循大多数教程时,我们会默认保留 ELSA 的端口 5000 和/或 5001,并且当我们创建 ASP.NET Core 项目时(至少对于命令行)位置 5000 和 5001 默认被占用,这就是它冲突的原因。

为了解决这个问题,我们必须进入Properties文件夹,在我们的ASP.NET Web项目的launchSettings.json文件中,在属性中更改端口,这样就可以解决冲突。

在此处查看图片

The problem that ERR_CONNECTION_REFUSED gives us in port 5001 is that, when we follow most of the tutorials, we leave port 5000 and/or 5001 by default of ELSA and when we create the ASP.NET Core project (at least with command lines) positions 5000 and 5001 are occupied by default, and that is why it conflicts.

To solve this problem, we must go to the Properties folder, in the launchSettings.json file of our ASP.NET Web project, and in the properties change the ports, and with this you can solve the conflict.

See image here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文