I have a REST backend ( using Go ) and want to send notifications to the clients whenever something happened on the server side.
I don't want to cover message brokers here, I know they exist. Most people seem to solve this by using websockets. But you could also have an additional API endpoint to stream data ( e.g. notifications ) via application/x-ndjson
( of course clients will have to parse the streamed data ).
I would like to know why most people seem to favor websockets over HTTP streaming.
- Because it's faster? ( How websockets can be faster than a simple HTTP request? )
- Because it's easier to implement? ( you don't have to parse a streamed json string )
I think introducting a second "protocol" of communication comes with new problems, right? So why not just stick with HTTP streaming?