Closed rwst closed 2 years ago
Is this definitely an SSE stream? I ask because the curl output in your description does not look like one. It's showing a series of text lines, each of which is a JSON object, but that is not the SSE format. An SSE event would have, at a minimum, a line starting with data:
and would be terminated by two linefeeds.
https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
That solves it, many thanks. This is not an SSE stream. As a suggestion maybe your code can give a hint when it encounters messages without data
.
I am using the library 'okhttp-eventsource' version 2.5.0 from https://github.com/launchdarkly/okhttp-eventsource/releases/tag/2.5.0 for SSE in Android. I am facing an issue where I can connect and receive signals, but after some time (around 5 minutes), the signals stop coming to my end, even if the backend is sending the signals and the SSE connection remains open.
The stream using curl:
As you can see there is one initial message and one message after each move, which I can trigger manually. There are also empty lines. Now my Kotlin code is:
This gives me the following log:
Nothing more, even if I trigger a move. Note the null lastEventId that I get after 5s. The
GameStreamEventHandler
=SSEventHandler
is simply overridingEventHandler
and logs every callback.My question: how can I debug further? In the end I may need to copy and tweak your code, but maybe you have an idea?