Hello,
I am trying to automate sqlmap through their API and I am having an error when creating a Request to the API

When I queue a Job I ask if the job is finished every second and sometimes the request just throws an error
Unhandled exception. System.Net.WebException: An error occurred while sending the request.
—> System.Net.Http.HttpRequestException: An error occurred while sending the request.
—> System.IO.IOException: The response ended prematurely.
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.HttpMessageHandlerStage.Send(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.SocketsHttpHandler.Send(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClientHandler.Send(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpMessageInvoker.Send(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken canc>
at System.Net.Http.HttpClient.Send(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at System.Net.HttpWebRequest.SendRequest(Boolean async)
at System.Net.HttpWebRequest.GetResponse()
— End of inner exception stack trace —
at System.Net.HttpWebRequest.GetResponse()
So I wrote a small test main which looks like this
So if I have the Sleep then the error takes a little bit longer but after a while I will start getting the error, without the sleep I get the error faster. The i variable has different values when I get this error, so its not happening at a specific time.
The sqlmapapi console is not showing any error, now I dont know if its an Code error from my side or an API error on sqlmap
Hope you can give me some help
This likely indicates the server closed the connection before the client got a full (or any) response.
Try running Wireshark and seeing what the actual wire packets look like to confirm.
Maybe your URL should be https — a https server would see a plaintext request and close the connection.
Ok, I could solve my problem, I was using .NET 5 after switching back to .NET Core 3.1 I dont have this problem anymore
It’s recommend to use HttpClient instead of WebRequest, so might be something funky going on with that.
Without the sleep you will just be flooding sqlmap with request in your while(true) loop


C# devs
null reference exceptions

source