[undertow-dev] Embedded undertow and atmosphere framework websockets

Dragan Jotanovic draganj at gmail.com
Tue May 13 09:54:52 EDT 2014


Hi,

I'm struggling to make simple chat atmosphere application to work with
embedded undertow.
The app seems to connect to websocket, and requests are passing through to
AtmosphereHandler but response never reaches client. I suppose that I'm
missing something in my undertow configuration but don't know what. Same
code works when dropped into Tomcat or Jetty.

Here is my bootstrap class:

public class Bootstrap {
    public static void main(String[] args) throws Exception {
        // deploy to undertow
        DeploymentInfo servletBuilder = Servlets.deployment()
                .setClassLoader(Bootstrap.class.getClassLoader())
                .setContextPath("")
                .setDeploymentName("chat")
                .setDefaultEncoding("UTF-8")
                .setUrlEncoding("UTF-8")
                .setResourceManager(new FileResourceManager(new File(""),
0))
                .addWelcomePage("index.html");
        servletBuilder.addServlet(Servlets.servlet("AtmosphereServlet",
AtmosphereServlet.class)
                .addInitParam("org.atmosphere.cpr.AtmosphereHandler",
"org.atmosphere.samples.chat.Chat")
                .addMapping("/chat/*")
                .setAsyncSupported(true));

        final WebSocketDeploymentInfo webSocketDeploymentInfo = new
WebSocketDeploymentInfo();

servletBuilder.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME,
webSocketDeploymentInfo);

        DeploymentManager manager =
Servlets.defaultContainer().addDeployment(servletBuilder);
        manager.deploy();

        HttpHandler servletHandler = manager.start();
        PathHandler path =
Handlers.path(Handlers.redirect("/")).addPrefixPath("/", servletHandler);
        Undertow server = Undertow.builder()
                .addHttpListener(8080, "0.0.0.0")
                .setHandler(path)
                .build();
        server.start();
    }
}

Does anyone know how to properly configure websockets support so that it
works with Atmosphere Framework?

Complete example can be seen here:
https://github.com/djotanov/atmosphere-undertow


Regards,
Dragan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20140513/6669de5b/attachment.html 


More information about the undertow-dev mailing list