Giter VIP home page Giter VIP logo

Comments (4)

jfarcand avatar jfarcand commented on May 28, 2024

Which version of AHC are you using under the hood? Let me take a look...

from wasync.

kbrems avatar kbrems commented on May 28, 2024

I am using async-http-client-1.7.9.

Based on my stack trace, it seems that HTP uses JDKAsyncHttpProvider by default. I found another forum where some people mentioned that Apache and JDK providors don’t really support websockets and that only Grizzly works. I could not figure out how to change providers in the example though since the provider instantiation is created inside ACT. I had better luck using the AHC directly without wasync and following the websocket example there in github. I downloaded the Grizzley websocket jar (2.3) and created a GrizzleyAsyncHttpProvidor. I was able to get this to work:

AsyncHttpClient client = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(new AsyncHttpClientConfig.Builder().build()));
String url = "ws://localhost:8084/VisualCall/websockets/?Content-Type=application/json&clientType=NS";
WebSocket socket = client.prepareGet(url)
.execute(new WebSocketUpgradeHandler.Builder().build())
.get();
WebSocket webSocketListener = socket.addWebSocketListener(new WebSocketTextListener() {

                @Override
                public void onMessage(String message) {
                  logger.log(Level.INFO, "Message Received: {0}", message);
                }

                @Override
                public void onOpen(WebSocket websocket) {
                  logger.info("WebSocket Opened");
                }

                @Override
                public void onFragment(String string, boolean bln) {
                    throw new UnsupportedOperationException("Not supported yet.");
                }

                @Override
                public void onClose(WebSocket ws) {
                    logger.info("WebSocket Closed");
                }

                @Override
                public void onError(Throwable thrwbl) {
                    logger.info("WebSocket Error");
                }
           });
    } catch (ExecutionException ex) {
        Logger.getLogger(VCBConnector.class.getName()).log(Level.SEVERE, null, ex);
    }

From: Jeanfrancois Arcand [mailto:[email protected]]
Sent: Monday, January 07, 2013 5:33 AM
To: Atmosphere/wasync
Cc: Brems, Karen (HP Labs)
Subject: Re: [wasync] I cannot get sample code to work (#2)

Which version of AHC are you using under the hood? Let me take a look...

β€”
Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-11951522.

from wasync.

jfarcand avatar jfarcand commented on May 28, 2024

You need to make sure either Netty or Grizzly jars are installed. That's why you got the error :-)

from wasync.

jfarcand avatar jfarcand commented on May 28, 2024

@brayanzimmerli take a look at the unit test. I will soon add a sample, before the 1.0 release.

from wasync.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.