Git Product home page Git Product logo

Comments (9)

belarusrulez avatar belarusrulez commented on September 24, 2024

I understand that it's okhttp3 issue.
It would be nice to have possibility to add interceptor in constructor or builder to make restart work around at least.
https://futurestud.io/tutorials/retrofit-2-catch-server-errors-globally-with-response-interceptor
while they are fixing this.

from client-jvm.

mmoghaddam385 avatar mmoghaddam385 commented on September 24, 2024

Hi @belarusrulez, is this exception making it to the websocket listener's onError callback?

There is a way to provide your own HttpClientProvider when constructing your websocket client. Your provider can extend DefaultJvmHttpClientProvider and override the buildClient function to return a custom ktor http client. Your custom client can have OkHttp interceptors or use a completely different engine like Apache. More details on Ktor client engines here: https://ktor.io/clients/http-client/engines.html. Just take a look at the default implementation of buildClient to see what features are required to be installed in the engine.

Ktor can be a bit awkward to work with, so let me know if you have more questions. In the meantime I'll look into making it simple to add OkHttp interceptors to the DefaultJvmHttpClientProvider

from client-jvm.

belarusrulez avatar belarusrulez commented on September 24, 2024

Thank you for response. Ill try this :)

from client-jvm.

belarusrulez avatar belarusrulez commented on September 24, 2024

Hello @mmoghaddam385 could you please rebuild it so Ill be able to use this https://github.com/polygon-io/client-jvm/blob/046cb1a3d653a0e0fd6936242d502b78692f052b/src/main/kotlin/io/polygon/kotlin/sdk/HttpClientProvider.kt changes?

Thank you :)

from client-jvm.

mmoghaddam385 avatar mmoghaddam385 commented on September 24, 2024

Oops, forgot to create a new release! Just created 1.1.0, should be good to go!

from client-jvm.

belarusrulez avatar belarusrulez commented on September 24, 2024

Hello, Thank you for quick response :)

I've tried to catch this exception .... like this:

image

looks like it never comes here :D still getting the same stacktrace and disconnect.

from client-jvm.

mmoghaddam385 avatar mmoghaddam385 commented on September 24, 2024

I was afraid that might happen, it doesn't seem like OkHttp interceptors really do all that much in websocket connections. At this point I'd suggest dropping OkHttp and trying out a different engine. The CIO engine (https://ktor.io/clients/http-client/engines.html#cio) support websockets and should be a drop-in replacement for OkHttp.

See the sample code for an example of how to swap out your http engine. (you'll also need to include the dependency from the ktor.io link above)

Let me know if you have any better luck with CIO, if you do I'll think about making that the default instead of OkHttp for now

from client-jvm.

mmoghaddam385 avatar mmoghaddam385 commented on September 24, 2024

Hi @belarusrulez, are you still having this issue?

from client-jvm.

mmoghaddam385 avatar mmoghaddam385 commented on September 24, 2024

I'm going to close this because I think the disconnects were being caused by a server-side issue at the time which has since been fixed. Feel free to re-open if I'm wrong though!

from client-jvm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.