Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sink sends empty bodies to endpoint #32

Closed
dskornalijnslijper opened this issue Oct 11, 2017 · 3 comments
Closed

Sink sends empty bodies to endpoint #32

dskornalijnslijper opened this issue Oct 11, 2017 · 3 comments
Labels
bug Something isn't working

Comments

@dskornalijnslijper
Copy link

Step 1: Describe your environment

Web Api running on Azure web app
.NET Framework 4.7
Serilog 2.5.0
Serilog.Sinks.RollingFile 3.3.0
Serilog.Sinks.PeriodicBatching 2.1.1
Serilog.Sinks.Http 4.2.0

Endpoint is a custom log storage api.

Step 2: Describe the problem

I have noticed the sink is sending HttpContent with an empty body to the HttpClient. Digging a bit deeper I see that, in HttpLogShipper.OnTick(), ReadPayload is always called and creates an empty payload when the end of file is reached. The code that follows will send the payload every 2 minutes (due to nextRequiredLevelCheckUtc), even if the payload is empty.

Is this behaviour by design (sending empty bodies)? If yes, why should the endpoint accept empty bodies?

Observed results

Sink is sending requests to the configured endpoint with empty bodies. Resulting in my case a response 400 Bad Request.

Expected results

Sink does not attempt to send anything unless there are events to dispatch to the endpoint.

@FantasticFiasco
Copy link
Owner

Hi dskornalijnslijper!

No, the behavior is not by design. I will look into it in the upcoming days and provide a fix for it.

Thanks for reporting the issue!

@dskornalijnslijper
Copy link
Author

Great, thanks! If you have trouble reproducing, let me know and I'll share more about my use case.

I am using a custom HttpClient wrapper and textFormatter. The HttpClient wrapper adds authentication and executes a PUT instead of a POST. The textFormatter is the same as the NormalTextFormatter but adds a field specific for my usecase. The batchFormatter is the DefaultBatchFormatter.

@FantasticFiasco
Copy link
Owner

Version 4.2.1 is now available on nuget.org.

Thanks for reporting the issue!

@FantasticFiasco FantasticFiasco added the bug Something isn't working label Oct 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants