Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSEStream unpredictably throws unwanted IOException("Canceled") #649

Closed
lijamie98 opened this issue Oct 28, 2024 · 1 comment
Closed

SSEStream unpredictably throws unwanted IOException("Canceled") #649

lijamie98 opened this issue Oct 28, 2024 · 1 comment
Assignees

Comments

@lijamie98
Copy link
Contributor

lijamie98 commented Oct 28, 2024

I encountered an unpredictable and unwanted exception thrown from the SSEStream of the Java Horizon SDK (https://github.com/lightsail-network/java-stellar-sdk).

java.io.IOException: Canceled
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:72)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at org.stellar.sdk.requests.ClientIdentificationInterceptor.intercept(ClientIdentificationInterceptor.java:22)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
    at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    ...

Here is the root cause:

When reconnectTimeout expires, restart is called
eventSource.cancel() is triggered.

A new StellarEventSourceListener is created for the new event source.

The previously canceled StellarEventSourceListener (the one that we don't track) can receive the IOException (Canceled) because the call was canceled in okhttp. The origin of the exception is here.

I suggest the SSEStream to not fire the onFailure() to the listener if the exception was targeting the canceled StellarEventSourceListener.

@lijamie98
Copy link
Contributor Author

Thank you so much for the fast fix. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants