Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sseclient can't detect end of next event? #27

Closed
docelic opened this issue Apr 11, 2019 · 4 comments
Closed

sseclient can't detect end of next event? #27

docelic opened this issue Apr 11, 2019 · 4 comments

Comments

@docelic
Copy link

docelic commented Apr 11, 2019

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.

@docelic
Copy link
Author

docelic commented Apr 11, 2019

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.

@docelic
Copy link
Author

docelic commented Apr 15, 2019

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

@docelic docelic closed this as completed Apr 15, 2019
@GPistre
Copy link

GPistre commented Dec 9, 2019

So, what was your solution ?

@docelic
Copy link
Author

docelic commented Dec 9, 2019

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants