简体   繁体   English

HTTP 端点不适用于 Elsa ERR_CONNECTION_REFUSED

[英]HTTP Endpoint not working with Elsa ERR_CONNECTION_REFUSED

I tried creating a web app in .Net standard 6.0 and added a simple workflow for HTTP Endpoint requests & responses.我尝试在 .Net 标准 6.0 中创建一个 Web 应用程序,并为 HTTP 端点请求和响应添加了一个简单的工作流程。 but the server URL returning ERR_CONNECTION_REFUSED with the URL(https://localhost:5001/data).但服务器 URL 返回 ERR_CONNECTION_REFUSED 和 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我正在使用 .Net Standard 6.0 和 Elsa 2.6

Program.cs程序.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应用设置.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.



When you want to invoke an HTTP endpoint, you need to use the same port as the one that is hosting Elsa.当您想要调用 HTTP 端点时,您需要使用与托管 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例如,如果您的 HTTP 端点活动配置为/start作为其路径,并且您的 Web 应用程序托管在https://localhost:7095/ ,那么您需要发出请求https://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).可以将 HTTP 端点中间件配置为侦听子路径(建议不要让中间件尝试将每个请求与工作流匹配)。 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那么你的 HTTP 端点的路径是: https://localhost:7095/workflows/start

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. ERR_CONNECTION_REFUSED在端口 5001 中给我们带来的问题是,当我们按照大多数教程进行操作时,我们会默认保留 ELSA 的端口 5000 和/或 5001,并且当我们创建 ASP.NET Core 项目时(至少使用命令行)位置5000和5001默认被占用,这就是冲突的原因。

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.要解决这个问题,我们必须到我们的ASP.NET Web项目的launchSettings.json文件中的Properties文件夹中,在属性中更改端口,这样就可以解决冲突了。

See image here在此处查看图片

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 HttpClient 在 GetAsync 上挂起 ERR_CONNECTION_REFUSED - HttpClient Hangs on GetAsync for ERR_CONNECTION_REFUSED ERR_CONNECTION_REFUSED - .Net Core 1.0.1 - ERR_CONNECTION_REFUSED - .Net Core 1.0.1 MVC应用程序文件结果在pdf上获得ERR_CONNECTION_REFUSED - MVC Application Fileresult get ERR_CONNECTION_REFUSED on pdf Plesk Linux ASP.NET Core ERR_CONNECTION_REFUSED - Plesk Linux ASP.NET Core ERR_CONNECTION_REFUSED ERR_CONNECTION_REFUSED 当我需要在 ASP.NET Core 中上传图片时 - ERR_CONNECTION_REFUSED When i Need to Upload Picture in ASP.NET Core 我的docker-compose asp.net核心项目未正确运行,我得到ERR_CONNECTION_REFUSED - My docker-compose asp.net core project is not properly running, I get ERR_CONNECTION_REFUSED 击中客户端连接端点时的ERR_INVALID_HTTP_RESPONSE - ERR_INVALID_HTTP_RESPONSE when hitting client connection endpoint WCF-没有端点在http localhost上侦听+无法建立连接,因为目标计算机主动拒绝了它=&gt;外部网络 - WCF - No endpoint listening at http localhost + No connection could be made because the target machine actively refused it => external network Http 请求从 xamarine 上的实际设备抛出“连接被拒绝”错误 - Http Request throws 'Connection Refused' error from actual device on xamarine WCF尝试公开nettcp端点; TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝它 - WCF trying to expose a nettcp endpoint; TCP error code 10061: No connection could be made because the target machine actively refused it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM