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.
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