Sitecore for Developers
Sitecore Commerce Engine Debugging – Invalid Request Line
Encounter with errors is business as usual for a developer every day, also it becomes more challenging when you are learning a new technology or implementation. I have been on a learning streak on Sitecore Commerce and would like to share such errors which I learnt by making mistakes, troubleshooting for hours, raising sitecore support tickets and what not.
I was facing this error
[22:51:05 INF] Connection id "0HLKD42HU85A2" bad request data: "Invalid request line: '\x16\x03\x01\x01\x01\x01\x00\x00\xFD\x03\x03\xF6\xC8\xCB\xB2\x87r\xC2\x86\xBE\xCB6\x0D\x84\x03\xC7\x8F\xD7\xDB\x94\xB6gtd3|\x10\x85k5\xC5h\xF6\x00\x00n\xC0/\xC0+\xC00\xC0,\x00\x9E\xC0'\x00g\xC0(\x00k\xC0$\xC0\x14\xC0\x0A'"Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Invalid request line: '\x16\x03\x01\x01\x01\x01\x00\x00\xFD\x03\x03\xF6\xC8\xCB\xB2\x87r\xC2\x86\xBE\xCB6\x0D\x84\x03\xC7\x8F\xD7\xDB\x94\xB6gtd3|\x10\x85k5\xC5h\xF6\x00\x00n\xC0/\xC0+\xC00\xC0,\x00\x9E\xC0'\x00g\xC0(\x00k\xC0$\xC0\x14\xC0\x0A' at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser`1.RejectRequestLine(Byte* requestLine, Int32 length) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser`1.GetUnknownMethod(Byte* data, Int32 length, Int32& methodLength) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser`1.ParseRequestLine(TRequestHandler handler, Byte* data, Int32 length) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser`1.ParseRequestLine(TRequestHandler handler, ReadableBuffer buffer, ReadCursor& consumed, ReadCursor& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame.TakeStartLine(ReadableBuffer buffer, ReadCursor& consumed, ReadCursor& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame.ParseRequest(ReadableBuffer buffer, ReadCursor& consumed, ReadCursor& examined) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame`1.<ProcessRequestsAsync>d__2.MoveNext()[22:51:09 INF] CacheWatcher.CacheTracking.NotFound in the environment HabitatAuthoring
As errors are mostly self explanatory at first glance it looked there might be an issue with Kestrel running on my machine.
Also, I was facing this issue only when I was running Sitecore Commerce Engine in Debugging mode from Visual Studio. Authoring role or Business Tool were working fine and they were not throwing error.
The main cause of this error was SSL certificate was missing from the Sitecore Commerce Engine project root folder. Making sure,
- The certificate is created, I followed Setup Visual Studio Environment for Commerce Engine Custom Plug-in Development and Debugging for creating the certificate.
- \src\Sitecore.Commerce.Engine\wwwroot\config.json file is updated with correct path to refer the certificate.
- Lastly the .pfx file has not been deleted accidentally, which was the case for me.
are the fixes.