Atmosphere / wasync

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

X-Atmosphere-TrackMessageSize header not set correctly #140

Closed byteit101 closed 7 years ago

byteit101 commented 8 years ago

When trying to track long messages, the headers are not properly set. The Javascript client works, but wasync doesn't:

AtmosphereClient atmoClient = ClientFactory.getDefault().newClient(AtmosphereClient.class);
Socket socket = atmoClient.create();   
Request request = atmoClient.newRequestBuilder()
          .method(Request.METHOD.GET)
          .uri("http://localhost:5555/hello")
          .transport(TRANSPORT.WEBSOCKET)
          .trackMessageLength(true)
          .build();
socket.on(Event.MESSAGE, new Function<String>() {
    @Override
    public void on(String message) {
        System.out.println(message.length() + " -- " + message);
    }
});
socket.open(request);

Result:

GET /hello?X-Atmosphere-Transport=websocket&X-Atmosphere-Framework=2.3.0&X-atmo-protocol=true&X-Atmosphere-tracking-id=0&X-Atmosphere-Transport=websocket&X-Atmosphere-Framework=2.3.0&X-atmo-protocol=true&X-Atmosphere-tracking-id=0 HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Origin: http://localhost:5555
Sec-WebSocket-Key: /qsN1Utd+mwdQIYo0MtXhg==
Sec-WebSocket-Version: 13
Host: localhost:5555
Accept: */*
User-Agent: wAsync/2.0

This stream then doesn't send the tracked message, just untracked messages. Also I'm not sure why all the headers were doubled on the second of the two(!) sockets that the above code opened.

Using Wasync 2.1.2

jfarcand commented 7 years ago

@byteit101 Pull requests welcomed...I've no time those days to work on wAsync, but I can review and integrate!

seamusmac commented 7 years ago

@jfarcand I ran into this today, and wasted a little bit of time, till I discovered this.

Any chance this could be released sometime soon, pretty please?

jfarcand commented 7 years ago

@seamusmac You owe me a beer...releasing 2.1.4 now!

jfarcand commented 7 years ago

Done!

thabach commented 7 years ago

Perfect 😉 !