btubbs/sseclient

sseclient can't detect end of next event?

docelic opened this issue · 4 comments

I am connecting to a server and not receiving any server-sent events.

After looking into the code, this is because in sseclient.py function next(), the code beginning with while not self._event_complete() never completes, so it doesn't complete and process any events, but it only appends to the internal buffer.

Any hints why this might be happening? Thanks.

Can the issue be in:

self.buf += decoder.decode(next_chunk)

End of field is searched using a regex r'\r\n\r\n|\r\r|\n\n', which leads me to believe that the content of self.buf should be string.

However, if I print self.buf, the content is all binary.

Found the root cause - the server's response is gzip-encoded and this is reaching the SSE client in raw form.

So, what was your solution ?

@GPistre one way is to decode gzip stream yourself.
However the solution I took was to send 'Accept-Encoding': 'identity' in the request headers to make sure that the server will respond with uncompressed data.