<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Dragan,<br>
    <br>
    ... I just had a similar issue a couple of days ago... my setup is
    slightly different from yours (using Spring behind the scenes), but
    it shouldn't matter...<br>
    <br>
    The problem was (in my case) the Atmosphere servlet mapping and the
    path parameter in the annotated handler service... <br>
    <br>
    I had (like you) an asterisk ("*") in the servlet mapping and that
    lead to a similar problem that you are describing (messages seem to
    arrive on the server side, but broadcasts to subscribed clients
    don't work).<br>
    <br>
    Also: Atmosphere was picky concerning the path parameter in my
    annotated handler service (see below).<br>
    <br>
    So... I'd suggest you try something like this (just showing the
    relevant parts):<br>
    <br>
    [java]<br>
    <br>
    public class Bootstrap {<br>
    ...<br>
    <br>
    &nbsp;&nbsp;&nbsp; .addMapping("/chat")<br>
    <br>
    ...<br>
    &nbsp;&nbsp;&nbsp; // Not sure if this is required and related to your problem...
    including it anyway...<br>
    &nbsp;&nbsp;&nbsp; final Xnio xnio = Xnio.getInstance("nio",
    Undertow.class.getClassLoader());<br>
    &nbsp;&nbsp;&nbsp; final XnioWorker xnioWorker =
    xnio.createWorker(OptionMap.builder().getMap());<br>
    &nbsp;&nbsp;&nbsp; final WebSocketDeploymentInfo webSockets = new
    WebSocketDeploymentInfo().setWorker(xnioWorker);<br>
    <br>
    &nbsp;&nbsp;&nbsp; servletBuilder.addServletContextAttribute(ATTRIBUTE_NAME,
    webSockets);<br>
    <br>
    ...<br>
    <br>
    &nbsp;&nbsp;&nbsp; final DeploymentManager manager =
    defaultContainer().addDeployment(servletBuilder);<br>
    &nbsp;&nbsp;&nbsp; manager.deploy();<br>
    <br>
    &nbsp;&nbsp;&nbsp; // Not sure if it matters, but I don't use a path handler<br>
    &nbsp;&nbsp;&nbsp; Undertow server = Undertow.builder()<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; .addHttpListener("8080", "localhost")<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .setHandler(manager.start())<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .build();<br>
    &nbsp;&nbsp;&nbsp; server.start();<br>
    }<br>
    <br>
    // Not sure if you are using the annotations... including it
    anyway... I think at least the path parameter has to be defined
    (interceptors can also be defined in servlet init param)...
    Atmosphere didn't pick the handler in my case when left out<br>
    @Singleton<br>
    @ManagedService(<br>
    &nbsp;&nbsp;&nbsp; path = "/{id}", <br>
    &nbsp;&nbsp;&nbsp; broadcasterCache = UUIDBroadcasterCache.class, <br>
    &nbsp;&nbsp;&nbsp; interceptors = {AtmosphereResourceLifecycleInterceptor.class,
    CorsInterceptor.class, TrackMessageSizeInterceptor.class,
    SuspendTrackerInterceptor.class}, <br>
    &nbsp;&nbsp;&nbsp; broadcaster = SimpleBroadcaster.class)<br>
    public class Chat {<br>
    ...<br>
    }<br>
    <br>
    [/java]<br>
    <br>
    ... and then on the client side:<br>
    <br>
    [javascript]<br>
    <br>
    var globalCallback = function (response) {<br>
    &nbsp;&nbsp;&nbsp; // do something<br>
    };<br>
    <br>
    var roomId = '123';<br>
    <br>
    var rq = $.atmosphere.subscribe('<a class="moz-txt-link-freetext" href="http://localhost:8080/chat/">http://localhost:8080/chat/</a>' +
    roomId, globalCallback, $.atmosphere.request = {<br>
    &nbsp;&nbsp;&nbsp; enableXDR: true,<br>
    &nbsp;&nbsp;&nbsp; logLevel: 'debug',<br>
    &nbsp;&nbsp;&nbsp; contentType: 'application/json',<br>
    &nbsp;&nbsp;&nbsp; transport: 'websocket',<br>
    &nbsp;&nbsp;&nbsp; onError: function (response) {<br>
    &nbsp;&nbsp;&nbsp; },<br>
    &nbsp;&nbsp;&nbsp; onClose: function (response) {<br>
    &nbsp;&nbsp;&nbsp; },<br>
    &nbsp;&nbsp;&nbsp; onOpen: function (response) {<br>
    &nbsp;&nbsp;&nbsp; },<br>
    &nbsp;&nbsp;&nbsp; onMessage: function (response) {<br>
    &nbsp;&nbsp;&nbsp; },<br>
    &nbsp;&nbsp;&nbsp; onReopen: function (request, response) {<br>
    &nbsp;&nbsp;&nbsp; },<br>
    &nbsp;&nbsp;&nbsp; onReconnect: function (request, response) {<br>
    &nbsp;&nbsp;&nbsp; },<br>
    &nbsp;&nbsp;&nbsp; onMessagePublished: function (response) {<br>
    &nbsp;&nbsp;&nbsp; },<br>
    &nbsp;&nbsp;&nbsp; onTransportFailure: function (reason, request) {<br>
    &nbsp;&nbsp;&nbsp; },<br>
    &nbsp;&nbsp;&nbsp; onLocalMessage: function (request) {<br>
    &nbsp;&nbsp;&nbsp; },<br>
    &nbsp;&nbsp;&nbsp; onFailureToReconnect: function (request, response) {<br>
    &nbsp;&nbsp;&nbsp; },<br>
    &nbsp;&nbsp;&nbsp; onClientTimeout: function(request){<br>
    &nbsp;&nbsp;&nbsp; },<br>
    &nbsp;&nbsp;&nbsp; callback: function () {<br>
    &nbsp;&nbsp;&nbsp; }<br>
    });<br>
    <br>
    [/javascript]<br>
    <br>
    Note: I am using the latest 2.2.0-RC1 jars with Atmosphere JQuery
    2.2.0<br>
    <br>
    Hope it helps...<br>
    <br>
    Cheers,<br>
    <br>
    Aleks<br>
    <br>
    <div class="moz-cite-prefix">On 13.05.2014 14:54, Dragan Jotanovic
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAJSsW4pnTAPqZxSR5h8oMvSDFkfREFh=qOHJPejNV67nz93Xxw@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi,
        <div><br>
          <div>I'm struggling to make simple chat atmosphere application
            to work with embedded undertow.</div>
          <div>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.</div>
          <div><br>
          </div>
          <div>Here is my bootstrap class:</div>
          <div><br>
          </div>
          <div>
            <div>public class Bootstrap {</div>
            <div>&nbsp; &nbsp; public static void main(String[] args) throws
              Exception {</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; // deploy to undertow</div>
            <div>
              &nbsp; &nbsp; &nbsp; &nbsp; DeploymentInfo servletBuilder =
              Servlets.deployment()</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
              .setClassLoader(Bootstrap.class.getClassLoader())</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setContextPath("")</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setDeploymentName("chat")</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setDefaultEncoding("UTF-8")</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setUrlEncoding("UTF-8")</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setResourceManager(new
              FileResourceManager(new File(""), 0))</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .addWelcomePage("index.html");</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp;
              servletBuilder.addServlet(Servlets.servlet("AtmosphereServlet",
              AtmosphereServlet.class)</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
              .addInitParam("org.atmosphere.cpr.AtmosphereHandler",
              "org.atmosphere.samples.chat.Chat")</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .addMapping("/chat/*")</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setAsyncSupported(true));</div>
            <div><br>
            </div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; final WebSocketDeploymentInfo
              webSocketDeploymentInfo = new WebSocketDeploymentInfo();</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp;
              servletBuilder.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME,
              webSocketDeploymentInfo);</div>
            <div><br>
            </div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; DeploymentManager manager =
              Servlets.defaultContainer().addDeployment(servletBuilder);</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; manager.deploy();</div>
            <div><br>
            </div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; HttpHandler servletHandler = manager.start();</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; PathHandler path =
              Handlers.path(Handlers.redirect("/")).addPrefixPath("/",
              servletHandler);</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; Undertow server = Undertow.builder()</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .addHttpListener(8080, "0.0.0.0")</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setHandler(path)</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .build();</div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; server.start();</div>
            <div>&nbsp; &nbsp; }</div>
            <div>}</div>
          </div>
        </div>
        <div><br>
        </div>
        <div>Does anyone know how to properly configure websockets
          support so that it works with Atmosphere Framework?</div>
        <div><br>
        </div>
        <div>Complete example can be seen here:</div>
        <div><a moz-do-not-send="true"
            href="https://github.com/djotanov/atmosphere-undertow">https://github.com/djotanov/atmosphere-undertow</a><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Regards,</div>
        <div>Dragan</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
undertow-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/undertow-dev">https://lists.jboss.org/mailman/listinfo/undertow-dev</a></pre>
    </blockquote>
    <br>
  </body>
</html>