Coder Social home page Coder Social logo

Comments (2)

eli-darkly avatar eli-darkly commented on June 18, 2024

I think that this is an issue with the backend, rather than the client. One way to verify whether my guess is right would be to load the same SSE URL from JavaScript code in a browser (like, just do new EventSource("http://localhost:8888/events")), look in the browser's Network tab, and see if it's showing any event traffic. Or, just do curl --raw http://localhost:8888/events from a Linux command line and see if the events are showing up as they're sent. If not, then the problem is not on the client side.

The client that we're using here is OkHttp, which handles gzip compression transparently. However, often when you enable gzip on a server, it will want to buffer the responses by default - since compression algorithms of this kind work best if you already know what the most frequently used characters are before you start doing the compression, which assumes that you've already seen more than a tiny piece of the data. And SSE can't work if the response is being buffered, no matter what client implementation you're using.

Of course, without access to your server, I have no way to know if that's the issue - and if I'm right, I can't give you any advice on how to disable buffering on your server, since that's a general issue that's outside the scope of maintaining the okhttp-eventsource code. And, again, we did not write the OkHttp client implementation so I'm not sure how much we would be able to do about this in any case. Still, please let me know what you see from either of the tests I mentioned above.

from okhttp-eventsource.

shengLin-alex avatar shengLin-alex commented on June 18, 2024

I think i found the reason why this approach not work, just remove
headerBuilder.add("Accept-Encoding", "br, gzip, deflate");

from okhttp-eventsource.

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.