Android Sinch PubNubListener: Permanently failing subscribe after 6 attempts - sinch

I get these errors on Samsung tab S3 and Galaxy S8 and more devices.
I suspect that this prevents me from establishing an app to app connection.
Any ideas what to configure to solve this?
Caller:
W/PubNubListener: Attempt 0 -> IO exception while subscribing for data. IllegalStateException rethrown as IOException due to Android API change
W/PubNubListener: Attempt 1 -> IO exception while subscribing for data. IllegalStateException rethrown as IOException due to Android API change
W/PubNubListener: Attempt 2 -> IO exception while subscribing for data. IllegalStateException rethrown as IOException due to Android API change
W/PubNubListener: Attempt 3 -> IO exception while subscribing for data. IllegalStateException rethrown as IOException due to Android API change
W/PubNubListener: Attempt 4 -> IO exception while subscribing for data. IllegalStateException rethrown as IOException due to Android API change
W/PubNubListener: Attempt 5 -> IO exception while subscribing for data. IllegalStateException rethrown as IOException due to Android API change
E/PubNubListener: Permanently failing subscribe after 6 attempts.
Callee:
W/PubNubPublisher: Attempt 0 -> IO exception while publishing. IllegalStateException rethrown as IOException due to Android API change
W/PubNubPublisher: Attempt 1 -> IO exception while publishing. IllegalStateException rethrown as IOException due to Android API change
W/PubNubPublisher: Attempt 2 -> IO exception while publishing. IllegalStateException rethrown as IOException due to Android API change
W/PubNubPublisher: Attempt 3 -> IO exception while publishing. IllegalStateException rethrown as IOException due to Android API change
W/PubNubPublisher: Attempt 4 -> IO exception while publishing. IllegalStateException rethrown as IOException due to Android API change
W/PubNubPublisher: Attempt 5 -> IO exception while publishing. IllegalStateException rethrown as IOException due to Android API change
E/PubNubPublisher: Permanent failure for publishing (after 6 attempts) message: 10 7f94c2a4-90d4-4f14-8c48-7f38adf20eb2 - 0 1 opLX7zLmxBxnNsYWjWDPd+hxK8PqPsZhaSGVrqFebNIEeEsrFH0aqWJf9Z+ys4bd1RsrWaAHBX24PU4RHym8Xaw1UfFL1jM3kb4ZESKg0RFIX8nD3bK5TEJQfTEeMZ6xKVdBYOOp9qgnnZWv9rmz0wOogq90ZFiYfkIeryxl0MMaPkfhnImowaPbY9vz3c1RjBJh02iRFpCnOJY3xpi+ZZwy+N8xa7VdyMDwqRpNm2sXVZSWkOyBTsXCKDRXZwIM

This was fixed in the new Sinch Android SDK version 3.12.6

Related

Prevent KafkaStreams punctuator from shutting down on CAUGHT exception

Using kafkastreams with Spring Boot, I have an exception that is caught in the punctuator like so:
try {
return record.toBuilder().apiResponse(userFeed.addActivity(activity).join()).success(Boolean.TRUE).build();
} catch (StreamException e) {
e.printStackTrace();
return record.toBuilder().success(Boolean.FALSE).build();
}
However, this exception is causing the streams app to shutdown:
org.apache.kafka.streams.errors.StreamsException: stream-thread [notification-service-StreamThread-1] task [0_2] Exception caught while punctuating processor 'KSTREAM-PROCESSOR-0000000001'
2023-01-20T15:39:33.269Z ERROR 1 --- [-StreamThread-1] org.apache.kafka.streams.KafkaStreams : stream-client [notification-service] Encountered the following exception during processing and the registered exception handler opted to SHUTDOWN_CLIENT. The streams client is going to shut down now.
How do I change the registered exception handler to not shut down the client? All the docs talk about uncaught exception handlers, but I am catching this exception. I don't even know what the registered handler is.
It turns out that the exception is not in fact caught correctly because of thread weirdness, so setting the uncaught exception handler fixed this.

How to return Custom Response for MaxUploadSizeExceededException during MultiPart File Upload Request?

I'm using a Spring Boot 2.7.5 Backend for a Multipart File Upload.
I want to return a Custom Response if the uploaded file exceeds the specified upload size limit in the configuration.
I originally tried using an ExceptionHandler in a ControllerAdvice as such:
#ExceptionHandler(value = [MaxUploadSizeExceededException::class])
fun handleSizeLimitExceededException(): ResponseEntity<Any> {
val fileSizeMegabyte = multipartProperties.maxFileSize.toMegabytes().toString()
val message = "The file is too big for the upload. Files are not allowed to be bigger than $fileSizeMegabyte MB"
LOG.warn(message)
return ResponseEntity(CustomErrorDto(FILE_TOO_LARGE, message, mapOf("maxFileSize" to fileSizeMegabyte)), HttpStatus.BAD_REQUEST)
}
Now this code gets executed, but it is ultimately ignored, as the Multipart Exception already gets handled (Connection Aborted) before the ControllerAdvice is even in play.
An exception occurred: java.lang.Throwable: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.lang.IllegalStateException: SRVE8021E: The file being uploaded is too large.
I tried using the spring.servlet.multipart.resolve-lazily: true property which seemed to work for some people in this thread here, as well as using an ErrorController (which is not applicable for my use case, as it is not a Spring MVC application)
Any hints will be much appreciated, so if you ever dealt with this or a similar issue, please let me know!
Thanks in advance!

SpringBoot application wont start after adding a filter

I added the following filter to my spring boot application.
#Component
public class RequestFilter implements Filter {
#Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse res = (HttpServletResponse) response;
String authorizationHeader = res.getHeader("Authorization");
System.out.println("auth :" + authorizationHeader);
chain.doFilter(req, res);
}
}
When I try to start the application locally it fails to start with this error message:
10-May-2022 17:09:43.268 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start. Full details will be found in the appropriate container log file
10-May-2022 17:09:43.269 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
10-May-2022 17:09:43.369 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal#8811a2]) and a value of type [org.springframework.security.core.context.SecurityContextImpl] (value [SecurityContextImpl [Null authentication]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
10-May-2022 17:09:43.369 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [com.hazelcast.client.impl.spi.impl.ClientResponseHandlerSupplier$1] (value [com.hazelcast.client.impl.spi.impl.ClientResponseHandlerSupplier$1#429304b7]) and a value of type [com.hazelcast.internal.util.MutableInteger] (value [com.hazelcast.internal.util.MutableInteger#378734f]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
[2022-05-10 05:09:43,390] Artifact *****.war exploded: Error during artifact deployment. See server log for details.
10-May-2022 17:09:45.941 INFO [hz.client_1.internal-2] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load [com.hazelcast.client.impl.protocol.codec.ClientPingCodec]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [com.hazelcast.client.impl.protocol.codec.ClientPingCodec]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1440)
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1428)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1267)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1228)
at com.hazelcast.client.impl.connection.tcp.HeartbeatManager.checkConnection(HeartbeatManager.java:94)
at com.hazelcast.client.impl.connection.tcp.HeartbeatManager.run(HeartbeatManager.java:78)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset$$$capture(FutureTask.java:308)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at com.hazelcast.internal.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76)
at com.hazelcast.internal.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:102)
The error suggests to find more details in the container logs.
When check the tomcat error logs on my local machine, there are no errors logged to it.
Any idea what might be causing this error? The problem is there is no relevant information in the tomcat log to debug this.

Throwing exception outside of Flux/Mono reactive pipeline

In my spring JMS listener onMessage method, I am using a reactive pipeline as as below where I receive a JMS message from a queue and transform that to a different format and publishing to another topic. Without the reactive flow, in the case of failure in output publishing, I can throw a runtimeexception for the same message to redeliver from the queue. But by using the below flow of reactive approach, I cannot find a way to throw an exception outside. Can you please help on what should be the approach here for throwing the exception outside to get the message redelivered
public void onMessage(Message message) {
Mono.just(message)
.doOnNext(LoggingUtil::logMessage)
.flatMapIterable(messageTransformer::transformToTriggerEvents)
.doOnNext(LoggingUtil::logTriggerEvent)
.doOnNext(triggerEventPublisher::publish)
.subscribe();
}

Kafka streams stopping threads on exception

In a kafka streams application if the process() method in your processor throws an uncaught exception the stream task will be killed. However if you have a punctuate() method (using context.schedule()) and it throws an uncaught exception the task will not be killed. Why is this? What is the proper way to kill the task if you wanted uncaught exceptions in punctuate() to stop the task?

Resources