square / okhttp

Square’s meticulous HTTP client for the JVM, Android, and GraalVM.
https://square.github.io/okhttp/
Apache License 2.0
45.81k stars 9.16k forks source link

Auto reconnect sse like browser does #5471

Closed erlangparasu closed 3 years ago

yschimke commented 5 years ago

Seems like a sensible feature to add

See discussion including Last-Event-Id here

https://kaazing.com/kaazing.io/doc/understanding-server-sent-events/ https://www.html5rocks.com/en/tutorials/eventsource/basics/

erlangparasu commented 5 years ago

thanks sir @yschimke :+1:

yschimke commented 5 years ago

We should also cleanup

  /**
   * TODO description.
   *
   * No further calls to this listener will be made.
   */
  open fun onClosed(eventSource: EventSource) {
  }
erlangparasu commented 5 years ago

https://github.com/square/okhttp/blob/aad8a1420d8f22a35138b92d7ecc14efc96155fe/okhttp-sse/src/main/java/okhttp3/internal/sse/RealEventSource.kt#L105

erlangparasu commented 5 years ago

hello sir.. other lib that provide auto retry: https://github.com/heremaps/oksse

Zaky7 commented 3 years ago

hi, can we have this feature?

yschimke commented 3 years ago

It's not currently in development, or confirmed on the near term roadmap. Sorry.

JakeWharton commented 3 years ago

I don't think OkHttp should support this. We don't automatically reconnect any persistent or long-lived connection as doing so requires all kind of public API to control the policy. This should be implemented at the application layer (or at least a layer above OkHttp).