Strange http response via boost - c++

Catching error message http_error_category::bad_reason as a result of http request via boost. What approximately does this error mean?

It means that parsing the reason did not succeed. E.g by unexpected end of input or illegal character data before the end of line.
The HTTP specification details the characters allowed as part of the first line of a HTTP response, and the code discloses what characters are prohibited in parse_token_to_eol.
Notable cause of this error may be when the server doesn't conform to the HTTP specification of requiring CRLF line ends (e.g. sending just '\n' instead of "\r\n")

Related

Filebeat regex for tomcat

I'm having trouble to get the correct regex for filebeat when using tomcat and log4j.
For this log:
21/10/2022 16:04:37 ERROR en Clase: ExceptionLogger - MSN: test
Exception.Class: BUSINESS EXCEPTION
ErrorCode: 0
Usuario: test
StackTrace:
at ar.com.test.conf.Monitor.monitorTest(ImpBusCaja.java:1213)
at ar.com.test.delegators.Monitor.m(Cajas.java:595)
I've configured this pattern: '^[[:space:]]' with negate=false and match=after (as the documentation says) but it doesn't work.
Even if I use the go playground, it should work: https://go.dev/play/p/JGV8ZDPtHwt
Here's what we have for configuration for log4j-based files with a slightly different pattern, but you should be able to adapt it to your situation:
multiline.type: pattern
multiline.pattern: '^\d{4}-\d{2}-'
multiline.negate: true
multiline.match: after
Here's an example standard log4j log line:
2022-10-22 13:55:34,932 [pool-8-thread-1] TRACE fully.qualified.class.Name- Here's the raw message
Here's an example exception message:
2022-10-21 20:14:42,442 [catalina-exec-6] ERROR fully.qualified.class.Name- Main error message
fully.qualified.exception.Type: Exception error message
at stack.trace.class.method(Source.java:103)
at stack.trace.class.method(Source.java:203)
at stack.trace.class.method(Source.java:303)
at stack.trace.class.method(Source.java:403)
So we are just looking for log lines starting with dddd-dd- and assuming that those are always "new log entries". We could certainly confuse things with a log line that was a continuation of something previous which started with that same pattern, but that's very rare.

Getting FR_3085 ERROR when working in Informatica

In a lot of the task flow jobs I'm running, I constantly am getting the
FR_3085 ERROR: Row [1]: 2-th character is a null character, which is
not allowed in a text input file
error. These occur usually in data synchronization tasks but I sometimes see this in mapping configurations as well. How do I resolve this error?
This error occurs when you have NULL characters in your flat file.
One way for doing this is using the OS utilities for removing the NULL characters from your flat file automatically and this will depend on what OS you're using.

file exception and cursor movement c++

I use exception handling while reading from a file to determine if the part I wish to store in a variable is of the correct type (eg. I don't want to store a string in a double variable), but when the exception occurs, the cursor won't go to the next line. Is there any possible way to do so?
If you have enabled exception for incorrect/failed input, the first wrong character in the input stream will raise the exception.
If your error processing consist of skipping the rest of the line to resume with the procesing of the next line, you have to clear the error status and then to ignore the unread chars of the line. Add the following in your exception processing code:
InputFile.clear(); // without this, every subsequent file op would fail
InputFile.ignore(std::numeric_limits<std::streamsize>::max(),'\n');
You should however take care, because >> reading from streams might skip newlines as well, so that a missing data might position you already on the next line. A safer approach would be to read the stream line by line with std::getline() and parse each line with a stringstream.

Logback pattern - do replace if message doesn't contain a word

This is a follow-up question for How to prevent logback/slf4j from parsing a new line character
I use following pattern to avoid strings with \n breaking into new line. But after using this pattern, my stacktraces come up with \n in the beginning which looks awkward.
<pattern>[%d{dd MMM yyyy HH:mm:ss,SSS}] [%5p] [%X{sid}] [%-20C{0} %25M]:[%-4L] - %replace(%m){'\n', '\\n'}%n</pattern>
Result stacktrace:
[21 Feb 2015 23:14:24] [ERROR] [21181422764] [myclass mymethod]:[221] - Socket exception occured while sending request for user. Stacktrace:= java.net.ConnectException: Connection refused: connect
\n at java.net.DualStackPlainSocketImpl.connect0(Native Method)
I've to change the replace to match only those %m that do not have "Exception" word in them. Not sure how to accomplish this in pattern. Also, I'm concerned about how this overall match and replace is adding to logging time cost and if it is acceptable cost.
It looks like you're manually formatting the exception as part of your message, but logback does this for you if you include the exception as an argument of the log call (see SLF4J API). I recommend using that API instead of attempting to include it in your message.
final Logger log = LoggerFactory.getLogger(Foo.class);
try {
// ...
} catch (IOException e) {
log.error("Socket exception occurred while sending request for user.", e);
}
If you're concerned with performance, note that by default, logback includes packaging information for each method in the stacktrace, which could be expensive, especially if your application frequently logs exceptions. To skip the package-info lookup, append %ex to your pattern layout.
In your example:
<pattern>... %replace(%m){'\n', '\\n'}%n%ex</pattern>

Getting HTTP xml error response using cURL

I am currently using cURL to communicate to a cloud site... everything is going well except for an annoying issue. The issue is that I cannot get the site's xml response when there is an error. for example, when I use Wire Shark to check the transfer I can see that in the HTTP header that I'm getting which contains the error code; there is an XML data that contains in addition to the error code, a message that describes the code. I have tried many cURL options to try and get the XML but all my attempts failed.
Could someone tell me how can I get the XML. please note that I'm using the cURL C APIs as my code is in c++ and moreover, I can get XML responses when the operation succeeds using my write callback function.
Set CURLOPT_FAILONERROR to 0. If this is set to 1, then any HTTP response >= 300 will result in an error rather than processing like you want.