Serilog Seq unable to send logs to http://localhost
See original GitHub issueI have the most trivial test app to experiment with Serilog Seq:
static void Main(string[] args)
{
try
{
Serilog.Debugging.SelfLog.Enable(Console.Error);
var logger = new LoggerConfiguration()
.WriteTo.Seq("http://localhost:5341")
.CreateLogger();
logger.Information("hello world");
Thread.Sleep(TimeSpan.FromSeconds(100));
}
finally
{
Log.CloseAndFlush();
}
}
The logs are pushed to a local docker instance running Seq, setup using instructions from https://docs.datalust.co/docs/getting-started-with-docker.
However, I continue to get the following error when the Seq serverUrl is http://localhost:5341
. I don’t get this error when the URL is changed to http://127.0.0.1:5341
. Is anyone able to help explain why that is?
FYI: I am able to POST a message to the Seq container using the following curl command: curl -XPOST "http://localhost:5341/api/events/raw?clef" -d "{'@t':'2018-06-07T03:44:57.8532799Z','@mt':'Hello, {User}','User':'alice'}"
, which makes me think this isn’t a local network issue.
2021-11-16T01:55:29.5226349Z Exception while emitting periodic batch from Serilog.Sinks.Seq.SeqSink: System.Net.Http.HttpRequestException: An error occurred while sending the request. —> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host… —> System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host. — End of inner exception stack trace — at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token) at System.Net.Http.HttpConnection.FillAsync(Boolean async) at System.Net.Http.HttpConnection.ReadNextResponseHeaderLineAsync(Boolean async, Boolean foldedHeadersAllowed) at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) — End of inner exception stack trace — at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken) at Serilog.Sinks.Seq.SeqSink.EmitBatchAsync(IEnumerable`1 events) at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.OnTick()
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
We are running into this exact same error message, but it is having the effect of adding logs every 15 seconds to our localhost seq server. This issue does not arise if the server is not localhost.
Configuration:
I don’t get the same error when using utilities like
curl
. The error is not likely specific to Serilog Seq library but potentially be with C# (or it’s underlying libraries). I just don’t understand why this inconsistency exists and was hoping someone in this community would know.