http client hanging on large (>8192) response.

358 views
Skip to first unread message

Finn Bock

unread,
Jun 5, 2012, 6:15:04 AM6/5/12
to ve...@googlegroups.com
Hi,

While trying the vertx test suite on windows I found a problem with the validation of the the sendFile test.

As far as I can see the server doing sendFile is behaving ok.

load('vertx.js')
var server = vertx.createHttpServer();

server.requestHandler(function(req) {
  req.response.sendFile("lib/jars/netty.jar")
}).listen(8080, 'localhost');

Pointing a browser to localhost will download the file just fine.

But using a http client to download the file:

load('vertx.js')

var log = vertx.logger;
var client = vertx.createHttpClient().setPort(8080).setHost('localhost')
var url = "http://localhost:8080/some-path";
client.getNow(url, function(resp) {
    log.info('Got a response, status code: ' + resp.statusCode);
    resp.dataHandler(function(buffer) {
        log.info('I received ' + buffer.length() + ' bytes');
    });  
    resp.endHandler(function() {
        log.info('I recieved end');
    });
});


will get me just one chunk of 8192 bytes

INFO: Got a response, status code: 200
INFO: I received 8192 bytes

and that is it. No further events arrive.

Since this is part of the test suite I'm almost certain that it is a windows only problem.

Tested with 1.0.1 and trunk.
On windows 7.
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b22)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)

I tried to add log output to DefaultHttpClient.ClientHandler, and it seems that netty only send one HttpResponse and one HttpChunk and no more. No other callback is invoked.

This is not an urgent problem and it can easily wait, if anybody happens to be on vacation right now. It is IMO better to relax and enjoy yourself then answering questions on mail lists.

regards,
Finn


Tim Fox

unread,
Jun 11, 2012, 6:23:08 AM6/11/12
to ve...@googlegroups.com
I can't replicate this on Linux, and I don't have Windows to hand.

Can you log out all the headers received at the client?

Also... can you add a github issue?

Thanks

makotan

unread,
Jun 11, 2012, 11:51:02 PM6/11/12
to ve...@googlegroups.com
add the last line of the client code.
Thread.sleep (10000);


2012年6月5日火曜日 19時15分04秒 UTC+9 Finn Bock:

Tim Fox

unread,
Jun 12, 2012, 3:02:00 AM6/12/12
to ve...@googlegroups.com
LOL. Good catch. ;)

I didn't realise this was using vert.x *embedded*. I assumed the code was in a verticle.

If embedded, then, as soon as the end of main() is reached it will exit (as is normal for Java programs). If you manage to read a chunk before that happens, that's a bonus ;)
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/ZDgSzQRFKiYJ.
To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/vertx?hl=en-GB.

Finn Bock

unread,
Jun 12, 2012, 3:12:35 AM6/12/12
to ve...@googlegroups.com


[Tim Fox]:
I can't replicate this on Linux, and I don't have Windows to hand.

Can you log out all the headers received at the client?

printing the headers in the client with:


    log.info('Got a response, status code: ' + resp.statusCode);
    for (k in resp.headers()) {
        log.info("header " + k + "=" + resp.headers()[k])
    }

I get:


INFO: Got a response, status code: 200
INFO: header Content-Length=973548

INFO: I received 8192 bytes


Also... can you add a github issue?

Probably not worth it, as I can reproduce the same problem using the HttpStaticFileServer and HttpSnoopClient from netty's examples;

http://netty.io/docs/stable/xref/org/jboss/netty/example/http/file/package-summary.html
http://netty.io/docs/stable/xref/org/jboss/netty/example/http/snoop/package-summary.html

So this is certainly not a problem with vertx.

If I switch java to 1.6

    java version "1.6.0_31"
    Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
    Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)

then the netty examples work. I have also tried

    java version "1.7.0_06-ea"
    Java(TM) SE Runtime Environment (build 1.7.0_06-ea-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 23.2-b03, mixed mode)

but it behave the same as 1.7.0_04

I'll take it to the netty group and see if they know about it.

regards,
Finn

Tim Fox

unread,
Jun 12, 2012, 3:12:36 AM6/12/12
to ve...@googlegroups.com
Having said that, the client code is JS, so can't be embedded, must be running as a Verticle....
To unsubscribe from this group, send email to vertx+unsubscribe@googlegroups.com.

Finn Bock

unread,
Jun 12, 2012, 3:17:58 AM6/12/12
to ve...@googlegroups.com


Den tirsdag den 12. juni 2012 09.12.36 UTC+2 skrev Tim Fox:
Having said that, the client code is JS, so can't be embedded, must be running as a Verticle....

Yes, it is a verticle.

/vertx.bat run client.js

regards,
Finn

Tim Fox

unread,
Jun 12, 2012, 3:55:05 AM6/12/12
to ve...@googlegroups.com
On 12/06/12 08:12, Finn Bock wrote:
>
>
> [Tim Fox]:
>
> I can't replicate this on Linux, and I don't have Windows to hand.
>
> Can you log out all the headers received at the client?
>
>
> printing the headers in the client with:
>
> log.info('Got a response, status code: ' + resp.statusCode);
> for (k in resp.headers()) {
> log.info("header " + k + "=" + resp.headers()[k])
> }
>
> I get:
>
> INFO: Got a response, status code: 200
> INFO: header Content-Length=973548
> INFO: I received 8192 bytes
>
>
> Also... can you add a github issue?
>
>
> Probably not worth it, as I can reproduce the same problem using the
> HttpStaticFileServer and HttpSnoopClient from netty's examples;
>
> http://netty.io/docs/stable/xref/org/jboss/netty/example/http/file/package-summary.html
>
> http://netty.io/docs/stable/xref/org/jboss/netty/example/http/snoop/package-summary.html
>
> So this is certainly not a problem with vertx.

Interesting. Have you tried playing with the TCP buffer sizes to see if
it makes a difference?
>
> If I switch java to 1.6
>
> java version "1.6.0_31"
> Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
> Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)
>
> then the netty examples work. I have also tried
>
> java version "1.7.0_06-ea"
> Java(TM) SE Runtime Environment (build 1.7.0_06-ea-b12)
> Java HotSpot(TM) 64-Bit Server VM (build 23.2-b03, mixed mode)
>
> but it behave the same as 1.7.0_04
>
> I'll take it to the netty group and see if they know about it.
>
> regards,
> Finn
>
> --
> You received this message because you are subscribed to the Google
> Groups "vert.x" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/vertx/-/pMto3TcgdlsJ.
> To post to this group, send an email to ve...@googlegroups.com.
> To unsubscribe from this group, send email to
> vertx+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/vertx?hl=en-GB.


--
Tim Fox

Vert.x - effortless polyglot asynchronous application development
http://vertx.io
twitter:@timfox

Tim Fox

unread,
Jun 12, 2012, 4:45:22 AM6/12/12
to ve...@googlegroups.com
Workaround would be to run vertx in a Linux VM on Windows.

To be honest, I would always recommend this for development rather than running vertx directly on Windows.
Reply all
Reply to author
Forward
0 new messages