While trying to run a project based on Ocelot's Configuration example on Ubuntu 16.04 with dotnet 2.1.403, the following exception is thrown:
Exception has occurred: CLR/System.AggregateException
An exception of type 'System.AggregateException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'One or more errors occurred.'
Inner exceptions found, see $exception in variables window for more details.
Innermost exception System.Exception : Unable to start Ocelot, errors are: reRoute /api/myapi has duplicate,reRoute /api/myapi has duplicate
at Ocelot.Middleware.OcelotMiddlewareExtensions.ThrowToStopOcelotStarting(Response config)
at Ocelot.Middleware.OcelotMiddlewareExtensions.<CreateConfiguration>d__4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Ocelot.Middleware.OcelotMiddlewareExtensions.<UseOcelot>d__2.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Ocelot.Middleware.OcelotMiddlewareExtensions.<UseOcelot>d__0.MoveNext()
Here are the contents of ocelot.json:
{
"ReRoutes": [
{
"DownstreamPathTemplate": "/myserver/myapi",
"DownstreamScheme": "http",
"UpstreamPathTemplate": "/api/myapi",
"UpstreamHttpMethod": ["Get", "Post"],
"DownstreamHostAndPorts": [{
"Host": "localhost",
"Port": 18080
}
]
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:8080"
}
}
The remaining contents of the project consist of the definitions stated in Ocelot's gettting started examples added to a clean ASP.NET Core empty project created with the dotnet CLI.
Does anyone know what might be triggering this exception?
@ruimaciel someone has had this error before but I don't think we worked out why. I would suggest getting the Ocelot source code in your project and debugging it to see if you can work out why.
@TomPallister ok fair enough, I'll keep you posted if I stumble on any additional info.
I encountered the duplicate reroute error while starting the application. It turns out that the code to add OceletServices was called once in Program.cs and another in Startup.cs. Removed the redundant code in Startup.cs and it works fine.
Most helpful comment
I encountered the duplicate reroute error while starting the application. It turns out that the code to add OceletServices was called once in Program.cs and another in Startup.cs. Removed the redundant code in Startup.cs and it works fine.