http端点不与elsa err_connection_refuse使用
我尝试在.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 技术交流群。

发布评论
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
当您想要调用 HTTP 端点时,您需要使用与托管 Elsa 的端口相同的端口。
例如,如果您有一个 HTTP Endpoint 活动,配置了
/start
作为其路径,并且您的 Web 应用托管在https://localhost:7095/
,那么您需要发出请求https://localhost:7095/start
注意
可以配置用于侦听子路径的 HTTP 端点中间件(建议中间件不要尝试匹配每个和针对工作流程的每个请求)。如果是这种情况,请确保也包含此路径。
例如,如果您执行了以下操作:
则 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 athttps://localhost:7095/
, then you need to make a requesthttps://localhost:7095/start
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:
Then the path to your HTTP Endpoint is:
https://localhost:7095/workflows/start