Search code examples
phpserver-sent-events

Event Source return data length


This article

enter link description here

provides an excellent introduction to Server Sent Events. The one thing that is not clear to me is this - they have a section entitled Multiline Data where they say "If your message is longer...". Longer than what? The statement seems to imply that long messages should be broken up into multiple data:value\n strings. If so, longer than what threshold length?

All I want to do is to send back a JSON string which I then process client side. The string contains, amongst other things HTML markup so it could get quite long - between 4 and 8 Kb would be typical. I should mention that my server side code is PHP.

Any help with this would be much appreciated.


Solution

  • Hmmm... No answers. I cannot say that I have found a definitive answer either but for the benefit of anyone running into this thread. Purely an empirical observation - there is no need to break up data into multiple lines just becuase there is a lot of it. In my own tests I have had no issues with data strings of up to 2048 characters. Given that I am unlikely to exceed that limit, the issue is solved AFAIC. A definitive answer from somone in the know would still be nice though.