[wildfly-dev] WF 8.0 HTTP Upgrade help needed

Stuart Douglas stuart.w.douglas at gmail.com
Thu Apr 3 00:18:17 EDT 2014


Can you try with the latest development build of Wildfly (from 
https://ci.jboss.org/hudson/job/WildFly-latest-master/).

There have been some fixes in this area, so your problem may have 
already been fixed.

Stuart


PB wrote:
> Hi,
>
> I'm testing the HTTP Upgrade feature of WF 8.0 and I'm facing some banal
> problem. Basically my ReadListener is NEVER called.
> Here's the code:
>
> @WebServlet(urlPatterns = "/upgrade")
> public class UpgradeServlet extends HttpServlet {
>    @Override
>    protected void doGet(HttpServletRequest req, HttpServletResponse
> resp) throws ServletException, IOException {
>      if ("upgrade".equalsIgnoreCase(req.getHeader("Connection"))) {
>        req.upgrade(EchoHandler.class);
>      }
>    }
> }
>
> public class EchoHandler implements HttpUpgradeHandler {
>    @Override
>    public void init(WebConnection wc) {
>      try {
>        ServletInputStream in = wc.getInputStream();
>        ServletOutputStream out = wc.getOutputStream();
>
>        BlockingQueue<String> queue = new LinkedBlockingQueue<String>();
>        in.setReadListener(new EchoReadListener(queue, in));
>        out.setWriteListener(new EchoWriteListener(queue, out));
>      } catch (IOException e) {
>        throw new IllegalStateException(e);
>      }
>    }
>
> public class EchoReadListener implements ReadListener {
>    @Override
>    public void onDataAvailable() throws IOException {
>      while (in.isReady()) {
>        int length = in.read(buffer);
>        String input = new String(buffer, 0, length);
>        if (false == queue.offer(input)) {
>          System.err.println("'" + input + "' input was ignored");
>        }
>      }
>    }
>
> I'm connecting to WF using telnet and sending the upgrade request:
> GET /example-webapp/upgrade HTTP/1.1
> Host: localhost
> Connection: upgrade
> Upgrade: echo
>
> and I'm getting correct response:
>
> HTTP/1.1 101 Switching Protocols
> Connection: Upgrade
> X-Powered-By: Undertow 1
> Server: Wildfly 8
> Content-Length: 0
>
> which means that from now on the protocol between my telnet client and
> WF is pure TCP.
> So, I start typing some text, hit Enter and.... nothing happens.
> onDataAvailable() is NEVER called. More so, this makes WF totally
> irresponsive - my whole webapp is dead.
>
> I believe, I'm doing something wrong - any ideas what exactly? There is
> also a slight chance that Upgrade feature in WF is f****d :)
> Anyway, WF should not block even in case my upgraded protocol is not
> working correctly?
>
> Many thanks,
> Przemyslaw
>
> _______________________________________________
> wildfly-dev mailing list
> wildfly-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/wildfly-dev


More information about the wildfly-dev mailing list