<div dir="ltr">Thanks for the quick reply, but unfortunately it didn't help.<div>I changed the mapping, removed asterisk, but it's still not working.</div><div>I'm not using any annotations or interceptors, it's the simplest setup possible.</div>
<div>Just an ordinary AtmosphereHandler implementation. AtmosphereHander is registered directly with AtmosphereFramework through init parameter of AtmosphereServlet.</div><div>You can see the full code at: <a href="https://github.com/djotanov/atmosphere-undertow">https://github.com/djotanov/atmosphere-undertow</a></div>
<div><br></div><div>I thought that I missed some configuration parameter in undertow but it seems that that is not the case since the same config works for you. I guess I will have to dig deeper into undertow code.</div><div>
<br></div><div>Thanks,</div><div>Dragan</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 13, 2014 at 4:01 PM, Aleksandar Vidakovic <span dir="ltr"><<a href="mailto:cheetah@monkeysintown.com" target="_blank">cheetah@monkeysintown.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div 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>
.addMapping("/chat")<br>
<br>
...<br>
// Not sure if this is required and related to your problem...
including it anyway...<br>
final Xnio xnio = Xnio.getInstance("nio",
Undertow.class.getClassLoader());<br>
final XnioWorker xnioWorker =
xnio.createWorker(OptionMap.builder().getMap());<br>
final WebSocketDeploymentInfo webSockets = new
WebSocketDeploymentInfo().setWorker(xnioWorker);<br>
<br>
servletBuilder.addServletContextAttribute(ATTRIBUTE_NAME,
webSockets);<br>
<br>
...<br>
<br>
final DeploymentManager manager =
defaultContainer().addDeployment(servletBuilder);<br>
manager.deploy();<br>
<br>
// Not sure if it matters, but I don't use a path handler<br>
Undertow server = Undertow.builder()<br>
.addHttpListener("8080", "localhost")<br>
.setHandler(manager.start())<br>
.build();<br>
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>
path = "/{id}", <br>
broadcasterCache = UUIDBroadcasterCache.class, <br>
interceptors = {AtmosphereResourceLifecycleInterceptor.class,
CorsInterceptor.class, TrackMessageSizeInterceptor.class,
SuspendTrackerInterceptor.class}, <br>
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>
// do something<br>
};<br>
<br>
var roomId = '123';<br>
<br>
var rq = $.atmosphere.subscribe('<a href="http://localhost:8080/chat/" target="_blank">http://localhost:8080/chat/</a>' +
roomId, globalCallback, $.atmosphere.request = {<br>
enableXDR: true,<br>
logLevel: 'debug',<br>
contentType: 'application/json',<br>
transport: 'websocket',<br>
onError: function (response) {<br>
},<br>
onClose: function (response) {<br>
},<br>
onOpen: function (response) {<br>
},<br>
onMessage: function (response) {<br>
},<br>
onReopen: function (request, response) {<br>
},<br>
onReconnect: function (request, response) {<br>
},<br>
onMessagePublished: function (response) {<br>
},<br>
onTransportFailure: function (reason, request) {<br>
},<br>
onLocalMessage: function (request) {<br>
},<br>
onFailureToReconnect: function (request, response) {<br>
},<br>
onClientTimeout: function(request){<br>
},<br>
callback: function () {<br>
}<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<div><div class="h5"><br>
<br>
<div>On 13.05.2014 14:54, Dragan Jotanovic
wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">
<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> public static void main(String[] args) throws
Exception {</div>
<div> // deploy to undertow</div>
<div>
DeploymentInfo servletBuilder =
Servlets.deployment()</div>
<div>
.setClassLoader(Bootstrap.class.getClassLoader())</div>
<div> .setContextPath("")</div>
<div> .setDeploymentName("chat")</div>
<div> .setDefaultEncoding("UTF-8")</div>
<div> .setUrlEncoding("UTF-8")</div>
<div> .setResourceManager(new
FileResourceManager(new File(""), 0))</div>
<div> .addWelcomePage("index.html");</div>
<div>
servletBuilder.addServlet(Servlets.servlet("AtmosphereServlet",
AtmosphereServlet.class)</div>
<div>
.addInitParam("org.atmosphere.cpr.AtmosphereHandler",
"org.atmosphere.samples.chat.Chat")</div>
<div> .addMapping("/chat/*")</div>
<div> .setAsyncSupported(true));</div>
<div><br>
</div>
<div> final WebSocketDeploymentInfo
webSocketDeploymentInfo = new WebSocketDeploymentInfo();</div>
<div>
servletBuilder.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME,
webSocketDeploymentInfo);</div>
<div><br>
</div>
<div> DeploymentManager manager =
Servlets.defaultContainer().addDeployment(servletBuilder);</div>
<div> manager.deploy();</div>
<div><br>
</div>
<div> HttpHandler servletHandler = manager.start();</div>
<div> PathHandler path =
Handlers.path(Handlers.redirect("/")).addPrefixPath("/",
servletHandler);</div>
<div> Undertow server = Undertow.builder()</div>
<div> .addHttpListener(8080, "0.0.0.0")</div>
<div> .setHandler(path)</div>
<div> .build();</div>
<div> server.start();</div>
<div> }</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 href="https://github.com/djotanov/atmosphere-undertow" target="_blank">https://github.com/djotanov/atmosphere-undertow</a><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Regards,</div>
<div>Dragan</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div></div><pre>_______________________________________________
undertow-dev mailing list
<a href="mailto:undertow-dev@lists.jboss.org" target="_blank">undertow-dev@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/undertow-dev</a></pre>
</blockquote>
<br>
</div>
<br>_______________________________________________<br>
undertow-dev mailing list<br>
<a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/undertow-dev</a><br></blockquote></div><br></div></div>