Wt and EventSource/SSE.

Added by Plug Gulp almost 1 year ago

I know that Wt has serverpush implemented as long-polling and websockets(bi-directional) But I am looking for an unidirectional serverpush such as SSE. Also there is a possibility that some corporate networks may block protocols like WS which could block websockets thus making Wt serverpush unavailable or falling back to long-polling. Hence a solution based on SSE would be more appropriate in such situations.

How would one go about implementing SSE support within Wt?

I am trying to implement an application that shoul be available on desktop and mobile. But looking at the chart and tables examples from widgets gallery it looks like the charts and tables get trimmed when on mobile devices. Hence I am bit hesitant to use Wt for mobile. So I have decided to use Flutter for mobile devices and Wt for desktop. But Wt's serverpush will not work with Flutter. And for the above reason I am also hesitant to use websockets. So I have the option of SSE.

What is the best way to support SSE within Wt?

Replies (3)

RE: Wt and EventSource/SSE. - Added by Wim Dumon 12 months ago

Hi Plug,

I believe Wt's long polling has benefits compared to SSE, so I wouldn't be afraid to fall-back to that. You'll always be sure your display is correct and consistent, and that no events get lost between browser and server. If your event update rate is too fast, the server will keep updating your UI and send aggregated updates at the rate that the client can consume them. I'd say it's superior to SSE.

SSE in Wt is easily implemented by using WResource.

That some of the Wt examples are not well behaving on mobile devices is because they were not designed for mobile devices rather than that it is impossible to do so in Wt. If you don't want to write your cross-platform CSS from scratch, I recommend to use bootstrap. That works really well in the projects we do. I also recommend against the use of Wt's layout managers, which are typically used to obtain a typical desktop-like look-and-feel, which is a somewhat unexpected pattern for users of web browsers.


RE: Wt and EventSource/SSE. - Added by Plug Gulp 12 months ago

Hey Wim,

I agree that Wt's in-built support for server-push is the better way for desktop web. But I am also planning on supporting mobile with Flutter for the front-end. For that I am thinking of using Wt as a backend with REST APIs and SSE for server-push to the Flutter-based mobile client.

I will go with Wt's server-push and use Bootstrap; and for native mobile clients I will implement SSE using WResource.

Btw, does Wt automatically switch to long-polling if websockets are blocked by client's network?

Thanks and kind regards,


RE: Wt and EventSource/SSE. - Added by Wim Dumon 12 months ago

Yes, there's an automatic fallback.