typesense / typesense-java

Java client for Typesense
https://typesense.org/docs/latest/api/
Apache License 2.0
60 stars 29 forks source link

Timeout exception #59

Open BilalZurmaati opened 3 months ago

BilalZurmaati commented 3 months ago

Description

Getting following exception and app crashes as well.

Fatal Exception: java.net.SocketTimeoutException failed to connect to search.bazaarghar.com/167.88.174.168 (port 443) from /192.168.1.3 (port 39918) after 2000ms

Expected Behavior

If the server is not working so I want to show some kind of error message but typesense straightaway throws this exception and app crashes.

Actual Behavior

The app crashes when on timeout exception.

Metadata

Typesense Version: 0.8.1

OS: Redmi 9C (Android 10)

kishorenc commented 3 months ago

Aren't you able to catch this exception in your code?

MatLeg25 commented 3 months ago

@BilalZurmaati , @kishorenc I have the same, got this output:

ERROR StatusLogger Unable to load services for service class org.apache.logging.log4j.spi.Provider
   java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.art/javalib/core-oj.jar)
    at org.apache.logging.log4j.util.ServiceLoaderUtil.callServiceLoader(ServiceLoaderUtil.java:109)
    at org.apache.logging.log4j.util.ServiceLoaderUtil$ServiceLoaderSpliterator.<init>(ServiceLoaderUtil.java:145)
    at org.apache.logging.log4j.util.ServiceLoaderUtil.loadClassloaderServices(ServiceLoaderUtil.java:100)
    at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:82)
    at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:76)
    at org.apache.logging.log4j.util.ProviderUtil.<init>(ProviderUtil.java:67)
    at org.apache.logging.log4j.util.ProviderUtil.lazyInit(ProviderUtil.java:145)
    at org.apache.logging.log4j.util.ProviderUtil.hasProviders(ProviderUtil.java:129)
    at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:90)
    at org.typesense.api.ApiCall.<clinit>(ApiCall.java:33)
    at org.typesense.api.Client.<init>(Client.java:28)
    at io.XXXXXXX.data.remote.TypesenseClient$1.run(TypesenseClient.java:69)
    at java.lang.Thread.run(Thread.java:1012)
  ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
  Accessing hidden method Ljava/lang/invoke/LambdaMetafactory;->metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; (blocked, linking, denied) 

    tagSocket(131) with statsTag=0xffffffff, statsUid=-1
    tagSocket(127) with statsTag=0xffffffff, statsUid=-1
  java.net.SocketTimeoutException: SSL handshake timed out
    at com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
    at com.google.android.gms.org.conscrypt.NativeSsl.doHandshake(:com.google.android.gms@243137039@24.31.37 (190408-662270918):11)
    at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(:com.google.android.gms@243137039@24.31.37 (190408-662270918):126)
    at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:379)
    at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337)
    at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209)
    at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
    at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
    at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
    at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
    at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
    at org.typesense.api.ApiCall.makeRequest(ApiCall.java:163)
    at org.typesense.api.ApiCall.get(ApiCall.java:118)
    at org.typesense.api.Health.retrieve(Health.java:15)
    at io.XXXXXXX.data.remote.TypesenseClient.getConnectionState(TypesenseClient.java:98)
    at io.XXXXXXX.data.remote.TypesenseClient$1.run(TypesenseClient.java:85)
    at java.lang.Thread.run(Thread.java:1012)
BilalZurmaati commented 3 months ago

Yes I did that way but I am just reporting it so that they return a failure instead of crashing the app. @kishorenc