Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Fwd: BOSH on ebmedded Jetty - server side.

It's good to hear it's possible but how to do that it's not clear. Are there a guidelines, documentation how this can be done?

Here is the code in our custom HttpServlet (the same is for doPost):

protected void doGet(HttpServletRequest request,
        HttpServletResponse response) throws ServletException,
    IOException {
        String rBody = readRequestContent(request);
        System.out.println(rBody);
        request.startAsync(request, response);
        AsyncContext acont = request.getAsyncContext();

        class MT extends Thread {
            AsyncContext acont;
            public MT(AsyncContext acont) {
                this.acont = acont;
            }
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {}

                HttpServletRequest req = (HttpServletRequest) acont.getRequest();
                HttpServletResponse resp = (HttpServletResponse) acont.getResponse();
                resp.setContentType("text/html");
                resp.setStatus(HttpServletResponse.SC_OK);
                try {
                    resp.getWriter().println("<h1>Hello from HelloServlet</h1>");
                } catch (IOException e) {
                    e.printStackTrace();
                }
                acont.complete();
            }
        }

        new MT(acont).start();

    }
}

Our HTTP client sends several requests and doesn't wait for a response before sending the next request.
We expect to get into this method before sending a response after 2000 mseconds but it never happens.




вт, 23 июл. 2019 г. в 21:35, Simone Bordet <sbordet@xxxxxxxxxxx>:
Hi,

On Tue, Jul 23, 2019 at 6:40 PM Sergey O <osnsergey@xxxxxxxxx> wrote:
>
> The problem is that we already have a client which we do not want to modify. It supports some BOSH subset (over one connection).
> CometD is not an options for us...

Well, then it's fairly easy to implement BOSH on the server if you
already have the client, it's basically just about handling the
long-poll.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

Back to the top