Long initial page load on firefox/chrome using faye/nodejs due to transport layer /meta/connect call

I'm having a strange issue with faye/nodejs where the page appears to be loading for a long time on an initial page load due to a /meta/connect call. This page load appears to last for exactly 45s (which is the value of the timeout set on the server)

Here are the details of the call:

The call in question is the following:

RAW GET: https://MYURL.com:8089/notifications?message=%5B%7B%22channel%22%3A%22%2Fmeta%2Fconnect%22%2C%22clientId%22%3A%220c3gocq1rwi3sl0dskn4u00e8wj7%22%2C%22connectionType%22%3A%22callback-polling%22%2C%22id%22%3A%225%22%7D%5D&jsonp=__jsonp3__

params: jsonp: __jsonp3__ message: [{"channel":"/meta/connect","clientId":"0c3gocq1rwi3sl0dskn4u00e8wj7","connectionType":"callback-polling","id":"5"}]

response: __jsonp3__([{"id":"5","clientId":"0c3gocq1rwi3sl0dskn4u00e8wj7","channel":"/meta/connect","successful":true,"advice":{"reconnect":"retry","interval":0,"timeout":45000}}]);

I've tried it without SSL, but the problem still persists, so it doesn't appear to be related to that.

The page is completely responsive during this time, but it's obviously an issue for my customers as they just see the loading bar in ff or chrome and they end up waiting the full 45 seconds for it to stop before proceeding. Any help in debugging or mitigating this issue is appreciated; possibly making the initial connect call asynchronous so it doesn't trigger on an initial page load?

I've also posted on the faye google group here: https://groups.google.com/forum/?fromgroups#!topic/faye-users/xZI4adt3DpA%5B1-25%5D

But I have not gotten a reply yet, though it does seem that I am not the only one with this issue.

Any help is appreciated.

Thanks!

Kevin

Just in case any future googlers stumble on this topic: the issue in question has been resolved in the newer versions of Faye. There are some further details on the google group link in my original question - the issue should be fixed as of faye 0.8.4 (currently 0.8.6)

I can confirm that this fixed the issue for me, I no longer see any timeouts on page load.

Sounds like you're not end()ing the response you're sending out, so your server is keeping the connection open.

When sending to channel /meta/connect add this to your params:

"advice":{"timeout": 0}

So your connect message should looks like that:

{"channel":"/meta/connect","clientId":"0c3gocq1rwi3sl0dskn4u00e8wj7","connectionType":"callback-polling","id":"5","advice":{"timeout":0}}

You can follow my solution starting with this place:

# server.rb
@engine.connect(response['clientId'], message['advice']) do |events|
  callback.call([response] + events)
end

...

# proxy.rb
def connect(client_id, options = {}, &callback)
  debug 'Accepting connection from ?', client_id
  @engine.ping(client_id)
  conn = connection(client_id, true)
  conn.connect(options, &callback)
  @engine.empty_queue(client_id)
end

...

# connection.rb
def connect(options, &block)
  options = options || {}
  timeout = options['timeout'] ? options['timeout'] / 1000.0 : @engine.timeout

  set_deferred_status(:deferred)
  callback(&block)

  begin_delivery_timeout
  begin_connection_timeout(timeout)
end

These methods are called when message comes to /meta/connect channel.