On Fri, Dec 14, 2012 at 6:24 PM, Tim Fox <
timv...@gmail.com> wrote:
> On 14/12/2012 18:15, Marek Majkowski wrote:
>> Your server should not close /htmlfile or /xhr_streaming requests after
>> 5 seconds. Streaming http requests are not time-bound. They should
>> be closed only when:
>> a) server application calls close() (you need to send close frame
>> before closing)
>> b) 128KiB (or other number, customized by user) of data is sent
>> over a single request.
>
> What if the client just disappears at this point? The session will be left
> on the server. With no timeout wouldn't that lead to a memory leak?
As I've written:
>> The 5 seconds timeout is for the situation when server closes
>> a long-polling or streaming request _and_ doesn't hear the
>> client to get back within 5 seconds. At this point, server
>> has no clue where the client had gone, so it can assume
>> the session is closed.
this is when 5 seconds thing kick. Basically - if a server
doesn't have a long-polling connection for a particular
session for longer than 5 seconds, it is free to
assume the session got closed and forget about it.
But that does not mean the server must close
a long polling / streaming http request every 5 seconds.
>> (you should send "h" frame every 25 seconds on /htmlfile or
>> /xhr_streaming,
>> to keep the connection alive in case of nasty load balancers)
>>
>> But all this may be irrelevant for this particular issue. SockJS-client
>> will automatically reconnect if server closes a streaming request.
>> Client responsibility is to reconnect to this /htmlfile request
>> and to do it promptly (5 seconds).
>
> Right.. I'm seeing it reconnect once, but if the second connection is closed
> by the server, it doesn't seem to reconnect again.
Does it call 'connection.onclose()' in client? Maybe it thinks the
server died.
> They all pass. I always run all the qunit + protocol tests before any vert.x
> release.
Ah, Cool!
>> b) please create a pcap network dump from the session
>> you feel went wrong (using wireshark or tcpdump). I may
>> be able to say something based on that.
>> (but please make it short, with one recorded session only)
How about the wireshark dump?
I tried to prepare a test replicating your setup - send messages
such long that they hit 128KiB limit and result in /htmlfile request
being closed. Run it like this:
http://localhost:8080/tests-qunit.html?filter=iframe-htmlfile%3A%20large%20download%20for%20Tim
It works for me (running chrome). It probably won't work over
the internet due to loads of data being transferred, but should
work fine locally. I'm not sure what that test proves - probably
nothing, but we'd learn something if it failed for vert.x
diff --git a/tests/html/src/tests.coffee b/tests/html/src/tests.coffee
index 90ef2db..03c782b 100644
--- a/tests/html/src/tests.coffee
+++ b/tests/html/src/tests.coffee
@@ -178,6 +178,36 @@ factor_batch_large = (protocol) ->
return batch_factory_factory(protocol, messages)
+xbatch_factory_factory_amp = (protocol, counter) ->
+ return ->
+ console.log "yes, this test is running!"
+ expect(3 + counter * 2)
+ r = newSockJS('/amplify', protocol)
+ ok(r)
+ sent = 0
+ recv = 0
+ r.onopen = (e) ->
+ ok(true)
+ r.send(''+17)
+ r.send(''+17)
+ sent += 2
+ r.onmessage = (e) ->
+ equals(e.data.length, Math.pow(2, 17), e.data)
+ recv += 1
+ if sent < counter * 2
+ r.send(''+17)
+ r.send(''+17)
+ sent += 2
+ if recv == sent
+ r.close()
+ r.onclose = (e) ->
+ ok(true)
+ start()
+
+xfactor_batch_large_amp = (protocol) ->
+ return xbatch_factory_factory_amp(protocol, 10)
+
+
batch_factory_factory_amp = (protocol, messages) ->
return ->
expect(3 + messages.length)
@@ -303,6 +333,8 @@ test_protocol_messages = (protocol) ->
asyncTest("large message (batch)", factor_batch_large(protocol))
asyncTest("large download", factor_batch_large_amp(protocol))
+ asyncTest("large download for Tim", xfactor_batch_large_amp(protocol))
+
asyncTest("user close", factor_user_close(protocol))
asyncTest("server close", factor_server_close(protocol))