Atmosphere / wasync

WebSockets with fallback transports client library for Node.js, Android and Java
http://async-io.org
161 stars 47 forks source link

NPE: scheme when opening the socket #149

Closed javydreamercsw closed 7 years ago

javydreamercsw commented 7 years ago

Trying to run the following code on Vaadin 7.7.10 which uses Atmosphere:

private final AtmosphereClient client
            = ClientFactory.getDefault().newClient(AtmosphereClient.class);

try {
            RequestBuilder request = client.newRequestBuilder()
                    .method(Request.METHOD.GET)
                    .uri("http//127.0.0.1/chat")
                    .trackMessageLength(true)
                    .transport(Request.TRANSPORT.WEBSOCKET)
                    .transport(Request.TRANSPORT.SSE)
                    .transport(Request.TRANSPORT.LONG_POLLING);
            Socket socket = client.create();
            socket.on(org.atmosphere.wasync.Event.MESSAGE, (Message t) -> {
                LOG.log(Level.INFO, "Received message: {0}", t.toString());
            }).on((Throwable t) -> {
                LOG.log(Level.SEVERE, null, t);
            }).on(org.atmosphere.wasync.Event.CLOSE.name(), (String t) -> {
                LOG.info("Connection closed");
            }).open(request.build());
        } catch (IOException ex) {
            LOG.log(Level.SEVERE, null, ex);
        }

Is giving a NPE in the following line: .open(request.build());

Here's the Exception:

java.lang.NullPointerException: scheme
    at com.ning.http.client.uri.Uri.<init>(Uri.java:56)
    at com.ning.http.client.uri.Uri.create(Uri.java:32)
    at com.ning.http.client.uri.Uri.create(Uri.java:25)
    at com.ning.http.client.RequestBuilderBase.setUrl(RequestBuilderBase.java:307)
    at com.ning.http.client.RequestBuilder.setUrl(RequestBuilder.java:165)
    at org.atmosphere.wasync.impl.DefaultSocket.open(DefaultSocket.java:119)
    at org.atmosphere.wasync.impl.DefaultSocket.open(DefaultSocket.java:109)

Any ideas?

jfarcand commented 7 years ago

.uri("http//127.0.0.1/chat") (Missing :)