4
2016-12-02 02:54:39:180 [WARNING] Microsoft.AspNetCore.Server.Kestrel -    Connection processing ended abnormally
Microsoft.AspNetCore.Server.Kestrel.BadHttpRequestException: The input string contains non-ASCII or null characters.
at Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.MemoryPoolIteratorExtensions.GetAsciiString(MemoryPoolIterator start, MemoryPoolIterator end)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame.TakeStartLine(SocketInput input)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()
2016-12-02 09:17:10:819 [ERROR] Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware - An unhandled exception has occurred: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at Gillie.JobCenter.Controllers.WebApi.QuestionnairesController.<SaveConsultant>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.AspNetCore.Mvc.Internal.ObjectMethodExecutor.<CastToObject>d__40`1.MoveNext()

I've got this exception only once, and i can't reproduce. Maybe someone know situations when this error is appears and i will try to reproduce.

Dima Grigoriev
  • 357
  • 5
  • 22
  • Well presumably, you've only once input a string containing `"non-ASCII or null characters"`. Did you actually read the error? it's very self explanatory – Alfie Goodacre Dec 23 '16 at 09:36
  • You can reproduce this if you have the original request that caused the error. You should check the *client* code. – Panagiotis Kanavos Dec 23 '16 at 09:38
  • It was on production, i don't have original request. But i've tried to use nonASCII characters and everything is okay – Dima Grigoriev Dec 23 '16 at 09:41
  • 1
    It looks like the error is actually in `QuestionnairesController.SaveConsultant` and is actually a `NullReferenceException`. But it's impossible for anyone to help without seeing your code. – DavidG Dec 23 '16 at 10:28
  • It's can't be connected with SaveConsultant method. if we have method SaveConsultant and problem with request this method will never execute correctly because server reject this request – Dima Grigoriev Jan 05 '17 at 14:00
  • 1
    As DavidG said, the error is you have a null reference in your SaveConsultant code. From what we can see, it maybe be *consultant* or *timeService* or *emailService*. You should add a check for these, like you do with *descryptedConsultant*. – Simon Mourier Jan 08 '17 at 11:06
  • In this case I could had "Object reference not set to an instance of an object" – Dima Grigoriev Jan 08 '17 at 22:35

1 Answers1

6

Rather than trying to guess at the input that can cause the error, you should probably be using HTTP log files to see what the actual request looked like. In my experience, staring at code without a really good clue to the source of a problem is unproductive. If you can't easily reproduce the problem, it's unlikely that any amount of guesswork with the code is going to help. You should be approaching the problem from the other end: trying to reproduce it. Identify the input that caused the error.

EDIT: Have you Googled this error message? It looks like others are having problems with Kestrel giving this message due to some bad cookies from the client. It may be a Kestrel bug in cookie handling. Perhaps just logging information about the cookies would be sufficient to identify the problem, and you would not need to log all the POST data. See https://github.com/aspnet/KestrelHttpServer/issues/949

Are you using an old version of Docker for Windows?

BlueMonkMN
  • 25,079
  • 9
  • 80
  • 146
  • I can't identify the input data, because it happened on production and i can't ask users. – Dima Grigoriev Jan 05 '17 at 14:07
  • 2
    Does that mean that you don't have the post data where you think the problem actually can be found? Sorry, I'm not very familiar with kestrel, but hopefully you can find a way to turn on or implement some HTTP POST logging until the problem occurs again. – BlueMonkMN Jan 05 '17 at 14:24
  • Did you mean log data from POST? It is not possible - it is private data – Dima Grigoriev Jan 05 '17 at 14:26
  • Then encrypt it before logging so that you can decrypt if you need to. And/or delete it if it didn't cause an error or is old. Somehow you need to get at the data that causes the error. – BlueMonkMN Jan 05 '17 at 14:29
  • Yes, i saw this post, but our application store one cookie for encoding password and it is all – Dima Grigoriev Jan 05 '17 at 15:20
  • If I understand correctly, it's not an application code issue, but a problem in the framework dealing with cookies possibly unrelated to the application. It seems you may just need to update to the latest version of Kestrel and/or Docker for Windows. – BlueMonkMN Jan 05 '17 at 15:21
  • Okay, thank you. But how i can be sure that updating version will fix this problem? – Dima Grigoriev Jan 05 '17 at 15:23
  • Use the information in the linked articles to try to reproduce the problem before fixing it. Otherwise, just hope and add more logging so you're better prepared if it happens again. – BlueMonkMN Jan 05 '17 at 15:26
  • I'm not sure that it connected with versions because this application works a long time and this exception was handeled only once – Dima Grigoriev Jan 05 '17 at 17:07
  • And i'm even don't have docker in Windows, app deployed on ubuntu – Dima Grigoriev Jan 12 '17 at 15:42