I have a java program inserting data, and it’s been fairly well tuned (using it constantly for 2 years), and can handle different error messages from influx when there’s an error inserting data. I’m using the http /write api endpoint by the way.
If we don’t get a 204 response code, We make an attempt to retrieve an error message which usually is sent back.
However, I have a particular data set insert which is causing a 400 code, but the server is closing the io error stream, thus causing an ioexception in my java program. “java.io.IOException: stream is closed” to be exact
relevant java code:
if (responseCode != 204) {
//get the response from the server.
Loggable logger = LoggingHelper.getLogger(CLASS_NAME, “sendDataToInflux”, LoggingReferences.S_OPERATION);
BufferedReader in = new BufferedReader(new InputStreamReader(con.getErrorStream(), “UTF-8”));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) { <<<<---------- this line, trying to do the in.readLine is causing io exception.
response.append(inputLine);
}
in.close();
.... Here we check the error message, log it, etc.
}
I can go ahead and add some additional try catch logic in this area for reading the error, but i’d really like to know why it closed the stream. When I run the same data through a second time, I don’t get this problem. I MUST delete the database, and perform the insert again to get this error.
I say all that to simply ask, is there a way to log an 404 response messages in the log on the server side?
This is all I’m getting for that insert in question:
Jul 5 16:06:15 perflocal2 influxd: [httpd] 127.0.0.1 - - [05/Jul/2018:16:06:14 -0400] “POST /write?db=myDB&precision=ms&rp=RP_4+Day%28s%29 HTTP/1.1” 400 72 “-” “Java/1.8.0_65” deb10c3d-808e-11e8-8695-000000000000 1395364
As an aside, I had the exact “stream is closed” errors when my insert was too big, but I got around that by setting max-body-size = 0 which seemed to do the trick.
So, hopefully someone can help point me in the direction of how to enable some logging on the server side so I can figure out why this insert is returning a 400 code.