https://issues.apache.org/bugzilla/show_bug.cgi?id=47500
Paul Gonchar <p...@coehl.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |p...@coehl.com --- Comment #1 from Paul Gonchar <p...@coehl.com> 2009-07-10 14:52:59 PST --- We have the same problem on Tomcat 6.0.18 and 6.0.20 (running on FreeBSD v7.2 amd64). Also, tried building from HEAD on 07/10/2009 with the same result. We are trying to implement a servlet based on CometProcessor. Here is a snippet of our server code: public void event( CometEvent _event ) throws IOException, ServletException { CometEvent.EventType type = _event.getEventType(); switch ( type ) { case BEGIN: // needed for APR connector if ( _event.getHttpServletRequest().getAttribute("org.apache.tomcat.comet.timeout.support") == Boolean.TRUE ) { _event.setTimeout( getTimeout() ); } break; case READ: processRead( _event ); _event.getHttpServletResponse().flushBuffer(); break; case END: case ERROR: _event.close(); break; } } In the next method the call to getParameter("message") prevents response from getting to the client. After some time some responses make it to the client, but these responses contain only headers (for example, "Connection" header set to "keep-alive" in the servlet by the call _event.getHttpServletResponse().addHeader("Connection", "keep-alive")) - no data is received. We tracked this in Firebug under Firefox 3.5 . If we invoke event.close() after processing of handshake(the same way it is done in BayeuxServlet.handleEvent(xxx) in the HEAD) then the client gets the response and servlet will get another "connect" request. However, there is nowhere to write the next response to because output stream is already closed. When we remove the call to _event.getHttpServletRequest().getParameter("message") everything works fine. private int processRead( CometEvent _event ) throws IOException, ServletException { String msg = _event.getHttpServletRequest().getParameter("message"); // ---------<<<<<<<< THE PROBLEM CALL try { JSONArray jobj = new JSONArray( msg ); for (int i = 0; i < jobj.length(); i++) { JSONObject jMsg = jobj.getJSONObject(i); PrintWriter out = _event.getHttpServletResponse().getWriter(); if ( "/meta/handshake".equals( jMsg.optString("channel") ) ) { out.print( "[" + handshake( jMsg) + "]" ); out.flush(); } else if ( "/meta/connect".equals( jMsg.optString("channel") ) ) { out.print( "[ { json response } ]" ); out.flush(); } } } catch ( Exception ex ) { throw new ServletException( ex ); } return 0; } private JSONObject handshake( JSONObject _msg ) throws JSONException { JSONObject response = new JSONObject(); response.put( "channel", "/meta/handshake"); response.put( "version", "1.0"); response.put( "minimumVersion", "0.9"); response.put( "clientId", bayeux.newClient().getId() ); response.put( "successful", true); response.put( "supportedConnectionTypes", new String[] { "long-polling", "callback-polling" } ); response.put( "id", _msg.optInt("id") ); return response; } Here is our test client page: <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="http://localhost:8180/dojo/1.3.1/dojo/dojo.js" djConfig="parseOnLoad: true, isDebug: true"> <script type="text/javascript"> dojo.require("dojox.cometd"); dojo.addOnLoad( function() { dojox.cometd.init("/functionaltest/cometd"); }); </script> </head> -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org