Question

I've looked here and there to try and figure out what server-sent events are on the transport level. I'm still not certain.

Both sources claim that they are "just http". There are, however, at least two ways in which I could interpret such a statement.

When I first read those articles I assumed that to mean that the server initiates a request to the client on the same port some other regular http request from the client to the server had been made previously. That should work with the address translation of normal home routers, but I was wondering about the implications of firewalls in corporate environments.

Later, however, I tried using SignalR with a Silverlight client and in my simple example it claimed to settle on using server-sent events as the transport. That makes sense, since the SignalR documentation says that WebSockets are unsupported in Silverlight and server-sent events are the next best choice.

In fiddler I then noticed a request that never finished - a hanging get - like you would expect with a transport of long polling. In contrast to long polling, however, the request would never finish, not even when data is actually sent. Wireshark revealed than this request is indeed used to establish a unidirectional channel from the server to the client: It's response is chunked and for each message the server sends a chunk.

But of course, in http parlance, this is still a request from the client to the server.

Since I couldn't find any source that mentions this rather important piece of information I'm asking whether someone could verify that this approach is indeed called server-sent events and that my SignalR client isn't lying to me.

(PS: After writing the question I noticed that the server-sent-events tag already tells me that the technique uses a persistent request from the client to the server. That is almost the whole confirmation I was seeking. I'm submitting this question anyway in case it might help someone find this information.)

Was it helpful?

Solution

After writing the question I noticed that the server-sent-events tag already tells me that the technique uses a persistent request from the client to the server. That is almost the whole confirmation I was seeking. I'm submitting this question anyway in case it might help someone find this information.

OTHER TIPS

Think of server-sent events like this, When a server receives a SSE request, the data is sent from the server as a write stream(hence for SSE, we use text/stream format). So whenever there is new data, it is automatically pushed to that stream. And the client receives it. It is a one way stream connection. If you need more info add a comment.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top