Data limits in server-sent events
Asked Answered
R

1

6

I'm using server-sent events in order to execute queries on your database. The server streams the stats in realtime with stats events and when the query is executed, it sends result event with the data and closes the connection.

You can test it with this curl command:

curl 'http://rakam-production-webapp-203653584.us-east-1.aws.getrakam.com/query/execute?read_key=l2drg09t1j04poki16q46nsa7qvjdjhsedcml0e9m8sd87h6olkevq8b7m3m6948&data=%7B%22query%22%3A%22SELECT%20*%20FROM%20collection.%5C%22pull_request%5C%22%22%2C%22limit%22%3A1000%7D' -H 'Accept: text/event-stream'

The problem is that is the data is more than a few kilobytes, EventSource doesn't trigger result event.

http://jsbin.com/jiteca/edit?html,output

It works fine if the data is not that big:

http://jsbin.com/leginu/edit?html,output

I tried Chrome, Safari and Firefox and all of them suffer from this issue. Any idea about how to solve this problem? Is this the limitation of server-sent events, because I didn't find anything on server-sent specification on W3?

Redcap answered 26/9, 2016 at 23:21 Comment(0)
K
1

I'm almost certain your problem is server-side, not a problem with the browsers, or their implementation of SSE. When I test your curl command it ends abruptly at this point:

...null,null,null],["2016-08-30T14:08:03Z","MichMich",

(Slightly different on each run.)

Not just misformatted JSON, but no double LF. My guess is either your web server process has crashed, or your back-end script has crashed. Take a look in the logs? Or if not a crash, then some buffer has filled up. (The message looks to be just over 313,000 bytes, which isn't ringing any bells.)

You didn't tag anything for the server-side language or web server, so it is hard to guess beyond that.

Kingpin answered 27/9, 2016 at 19:38 Comment(1)
I didn't even consider that my application may not be sending the full data. Thanks for pointing out!Redcap

© 2022 - 2024 — McMap. All rights reserved.