Content length mismatch : too many bytes written

Prem Jha 6 Reputation points
2022-07-21T11:09:52.657+00:00

i am running a API in aks cluster with is wriiten in .NET.

when i am hitting the logs of API it is showing me this error:

System.InvalidOperationException: Response Content-Length mismatch: too many bytes written (58398 of 58365).

i am suspecting that nginx is blocking the response due to the content length mismatch. which is creating the issue.

how can i resolve this issue.?

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,221 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Summer Hudson 1 Reputation point
    2022-09-09T21:02:44.987+00:00

    Was there an answer to this? I have a web service running in azure AKS behind azure agic. Locally it works fine. I am sending data over a websocket connection:

     await this.WebSocket.SendAsync(msgbuf, WebSocketMessageType.Text, endOfMessage: true, CancellationToken.None);  
    

    However, deployed in AKS I get this error:

    System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake.
    9/9/2022, 3:54:47 PM
    engageapiapp-69858df8dc-kmd7c
    798d7d41e13331a3d47c036600ea0a0429ce6993acd7c0f8e601339ed3f83306
    ---> System.InvalidOperationException: Response Content-Length mismatch: too many bytes written (83 of 0).
    9/9/2022, 3:54:47 PM
    engageapiapp-69858df8dc-kmd7c
    798d7d41e13331a3d47c036600ea0a0429ce6993acd7c0f8e601339ed3f83306
    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.VerifyAndUpdateWrite(Int32 count)
    9/9/2022, 3:54:47 PM
    engageapiapp-69858df8dc-kmd7c
    798d7d41e13331a3d47c036600ea0a0429ce6993acd7c0f8e601339ed3f83306
    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.WritePipeAsync(ReadOnlyMemory1 data, CancellationToken cancellationToken) 9/9/2022, 3:54:47 PM engageapiapp-69858df8dc-kmd7c 798d7d41e13331a3d47c036600ea0a0429ce6993acd7c0f8e601339ed3f83306 at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseStream.WriteAsync(ReadOnlyMemory1 source, CancellationToken cancellationToken)
    9/9/2022, 3:54:47 PM
    engageapiapp-69858df8dc-kmd7c
    798d7d41e13331a3d47c036600ea0a0429ce6993acd7c0f8e601339ed3f83306
    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpUpgradeStream.WriteAsync(ReadOnlyMemory1 source, CancellationToken cancellationToken) 9/9/2022, 3:54:47 PM engageapiapp-69858df8dc-kmd7c 798d7d41e13331a3d47c036600ea0a0429ce6993acd7c0f8e601339ed3f83306 at System.Net.WebSockets.ManagedWebSocket.SendFrameLockAcquiredNonCancelableAsync(MessageOpcode opcode, Boolean endOfMessage, Boolean disableCompression, ReadOnlyMemory1 payloadBuffer)


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.