Salut,
Sreenivas Munnangi wrote:
> Hi,
>
> We are able to get comet work with a simple java client and we are
> planning on enhancing it for production use.
>
> Basically we are planning to use a single servlet (attached war with
> servlet) which will serve multiple clients using contextPath and
> corresponding handler. Somehow the client (attached client code) doesn't
> get the response back and it keeps hanging. Based on the debug info,
> the onEvent method got invoked (made sure to flush the writer several
> times) but the response is not received by the client. Do you spot
> anything obvious ?
Not sure I understand why you invoking flush so many times :-) Just one
it should works.
First, I haven't try but:
> protected void doPost(HttpServletRequest req, HttpServletResponse res)
> throws ServletException, IOException {
> String contextPath = req.getParameter("script");
> String message = req.getParameter("message");
> CometEngine engine = CometEngine.getEngine();
> if (message == null) {
> if (contextPath != null) {
> CometContext cc = engine.getCometContext(contextPath);
> if (cc == null) {
> cc = engine.register(contextPath);
> cc.setExpirationDelay(30000 * 1000);
> CometMsgHandler handler = new CometMsgHandler();
> handler.attach(res);
> cc.addCometHandler(handler);
> cc.notify("init");
> }
> }
> } else {
> CometContext cc = engine.getCometContext(contextPath);
> if (cc != null) {
> cc.notify(message);
> }
>
> }
> }
if cc == null you will never notify, hence no msg. You should add some
debug statement here to make sure cc is never null.
Can you install ngrep.sourceforge.net or wireshark and make sure you are
writting something back? One way to make sure is to resume the
CometHandler inside the onEvent method, e.g invoking:
event.getCometContext().resumeCometHandler(this).
Also from:
> if (message == null) {
> if (contextPath != null) {
> CometContext cc = engine.getCometContext(contextPath);
> if (cc == null) {
> cc = engine.register(contextPath);
> cc.setExpirationDelay(30000 * 1000);
> CometMsgHandler handler = new CometMsgHandler();
> handler.attach(res);
> cc.addCometHandler(handler);
> cc.notify("init");
> }
> }
if the cc != null you are doing nothing, which explain probably why you
aren't geting any data.
A+
--Jeanfrancois
>
> Pl. let us know if you need more info.
>
> Appreciate your help.
>
> thanks
> sreeni
>
>
>