Specify server push transport mode at runtime

Hello,

the Push annotation defines the PushMode and the Transport to be used for server push configuration. An alternative approach for specifying the push mode is to define the servlet init parameter pushMode, pushMode = automatic for example. Is there a similar alternative approach for specifying the transport, transport = long-polling or transport = websocket-xhr for example ?

Cheers,
Martin.

It seems there is none. Neither of https://vaadin.com/docs/v13/flow/advanced/tutorial-flow-runtime-configuration.html and https://vaadin.com/docs/v13/flow/advanced/tutorial-all-vaadin-properties.html mentions it.

The potential workaround from https://vaadin.com/forum/thread/8760508/13862974 no longer works and you would have to use an initialization listener or similar for that.

What you can do of course is to set the push mode via command line parameter. I think mvn jetty:run -Dpushmode=automatic should work.

Referring to your title - it might technically be possible to change the mode during runtime but as this something the container and not the application controls you’d need something like JMX/MBeans or a server-specific API to achieve that. Also, pretty sure your application would need a complete refresh after that.

Thanks Ronny.

After reading your response I have realized an error in my actual question. It should really be to specify the transport at container start time not after the container has been started. I want to avoid using the Push annotation as this hard-codes the choices.

I will review the Apache Tomcat documentation (I am using the embedded version) to see if I can determine how to specify it.

Cheers,
Martin.