I am using ejabberd 15.11. While a client is trying to retrieve message from archive getting below error in error logs. My client is sending and receiving encrypted messages
Error log:
[error] <0.2337.0>#gen_iq_handler:process_iq:128
{
{badmatch,{error,{4,<<"not well-formed (invalid token)">>}}},
[
{mod_mam,'-select/8-fun-4-',3,[{file,"src/mod_mam.erl"},{line,681}]},
{lists,map,2,[{file,"lists.erl"},{line,1237}]},
{mod_mam,select,8,[{file,"src/mod_mam.erl"},{line,677}]},
{mod_mam,select_and_send,10,[{file,"src/mod_mam.erl"},{line,577}]},
{gen_iq_handler,process_iq,6,[{file,"src/gen_iq_handler.erl"},{line,127}]},
{gen_iq_handler,handle_info,2,[{file,"src/gen_iq_handler.erl"},{line,171}]},
{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,593}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,659}]}
]
}
crypto:block_encrypt(Type, Key, Ivec, PlainText)is not working insted of it try to use crypto:aes_cfb_128_encrypt(Key, Ivec, PlainText) function.
Related
I have implemented custom kafkalistenererrorhandler. I want to send the message to retry topic if message fails in processing. For this purpose I have added some headers to it. For doing this I am using spring-meesage.
Issue is when I am sending message using kafkatemplate it adds "\" to the string message.
Following is the code what I am doing.
public Object handleError(Message<?> message, ListenerExecutionFailedException exception) {
logger.info("Enter handleError message");
int numberOfRetries = messageRetryCount(message);
MessageBuilder<?> messageBuilder = MessageBuilder.fromMessage(message).removeHeader(KafkaHeaders.TOPIC)
.removeHeader(KafkaHeaders.PARTITION_ID).removeHeader(KafkaHeaders.MESSAGE_KEY)
.setHeader(KafkaHeaders.TOPIC, numberOfRetries > 0 ? retryTopic : dlqTopic);
template.send(messageBuilder.build());
Internally spring-kafka converts message to producerRecord. which in output adds \ to the string.
2020-03-20 12:25:28.804 INFO 10936 --- [_consumer-0-C-1] c.h.kafkaretry.consumer.SimpleConsumer : in rety :: "\"testfail\""
Does anyone faced same issue ? any alternatives or solution ?
Looks like you use JsonSerializer while your data is just a plain string. Consider to use a StringSerializer or JsonDeserializer on the consumer side.
I am working with the Facebook graph API and have run into trouble regarding handling failed requests.
I use this code to create a new post
SocialFacebook.createPosting = function(data) {
var options = {
params: {
access_token : data.tokens.accessToken,
message : data.text
}
};
var url = 'https://graph.facebook.com/' + data.graphId + '/feed';
var response = HTTP.call('POST', url, options).data;
return response;
}
But instead of returning a JS object with error information in the response, it throws an error on failed requests
Exception while invoking method 'createPosting' Error: failed [500] {"error":{"message":"Duplicate status message","type":"FacebookApiException","code":506,"error_subcode":1455006,"is_transient":false,"error_user_title":"Duplicate Status Update","error_user_msg":"This status update is identical to the last one you posted. Try posting something different, or delete your previous update."}}
Because it's wrapped in an Error, the otherwise JSON object is now a string with some other stuff appended to it, which makes it difficult to parse and extract the attributes
Any idea as to why it throws an error, instead of returning a JS object with error details like usually?
Much appreciated
According to the docs, about HTTP.call():
On the server, this function can be run either synchronously or asynchronously. If the callback is omitted, it runs synchronously and the results are returned once the request completes successfully. If the request was not successful, an error is thrown.
So there you have it: since you called HTTP.call() synchronously (without providing a callback), if it responds with an error (in your case, Code 500) the error is thrown and not included in the data.
Implementing mule pgp encryption decryption for an xml file. While decryption its raises an error
ERROR 2015-06-05 12:06:34,192 [Thread-8] org.mule.module.pgp.AbstractTransformPolicy: Invalid PGP message
java.lang.IllegalArgumentException: Invalid PGP message
at org.mule.module.pgp.DecryptStreamTransformer.initialize(DecryptStreamTransformer.java:79)
at org.mule.module.pgp.TransformContinuouslyPolicy$ContinuousWork.execute(TransformContinuouslyPolicy.java:60)
at org.mule.module.pgp.AbstractTransformPolicy$TransformerWork.run(AbstractTransformPolicy.java:109)
I debugged mule pgp package and in DecryptStreamTransformer
public void initialize(OutputStream out) throws Exception
{
InputStream decodedInputStream = PGPUtil.getDecoderStream(this.toBeDecrypted);
PGPObjectFactory pgpF = new PGPObjectFactory(decodedInputStream);
Object o = pgpF.nextObject();
if (o == null)
{
throw new IllegalArgumentException("Invalid PGP message");
}
What might be the reasons of PGPObjectFactory returning nextObject as null. Also logging message payload after flow element
<decrypt-transformer name="decryptTransformer" strategy-ref="pgpEncryptionStrategy"/>
<logger level="INFO" doc:name=" Message Logger" message="#[payload]"/>
<mulexml:jaxb-xml-to-object-transformer
jaxbContext-ref="jaxb" doc:name="JAXB-Unmarshaller"
returnClass="com.generated.Communication" />
Payload is displayed as
org.mule.module.pgp.LazyTransformedInputStream#17d80e9.
How can i modify this instance to xml so that mulexml jaxb element can marshall this to required object.
As seen in its source code:
registerSourceType(DataTypeFactory.INPUT_STREAM);
the jaxb-xml-to-object-transformer accepts any input stream as a valid source, so the issue is not there.
I am developing an app that appends all the values of the form to a FormData() object e.g. "msgBody" and sends it to the grails server-side where it is consumed by jax-rs api. I have used something like:
GrailsWebRequest request = WebUtils.retrieveGrailsWebRequest()
def params = request.getParams()
if (!(params.msgBody.length() > 0)) {
log.error("Empty message body")
}
The problem I am having is with the integration testing of that api where I have written:
def headers = ['Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryZ7dAiucrA3eTbjzI', 'Accept': 'application/json']
def content='{"msgBody":"Hello World"}'
sendRequest("/api/v1/message", 'POST', headers, content.bytes)
I keep on getting the "500 Internal Server Error" and error message:
"Caused by: java.lang.NullPointerException: Cannot invoke method length() on null object".
Why is this happening?
I have found out that you don't need to set the Content-Type in the headers and you also have to set all the fields of the FormData() object even if they are null. I did so but still I am getting the same NullPointerException message.
I have a thread class which makes a web request. After 20-30 urls request, its throwing exception: System.Web.HttpException: Request timed out.
My code is below where it is throwing exception:
httpReq.AllowAutoRedirect = false;
httpReq.KeepAlive = false;
httpReq.Headers.Add("Location", "");
httpReq.Timeout = this.HttpRequestTimeout;
httpRes = (HttpWebResponse)httpReq.GetResponse();
In last line : httpRes = (HttpWebResponse)httpReq.GetResponse();
it is throwing exception.
"The remote server returned an error: (403) Forbidden."
I am using session for setting some values with the request header.
I got the answer. I was not using httpRes.close() method after using response object. That's why after 80-90 request it was returning : "The remote server returned an error: (403) Forbidden ".