Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Faye js client doesn't connect properly
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Frank Razenberg  
View profile  
 More options Aug 30 2012, 11:38 am
From: Frank Razenberg <zzatt...@gmail.com>
Date: Thu, 30 Aug 2012 08:38:13 -0700 (PDT)
Local: Thurs, Aug 30 2012 11:38 am
Subject: Faye js client doesn't connect properly

Hi James and group,
I have a simple setup with the faye server on node, and am using the faye
js client. My problem is that the client doesn't seem to connect properly
most of the time. I need about 3-4 browser refreshes before I successfully
connect to the node server.

The connect code is dirt-simple:
var fayeClient;
$(document).ready(function () {
fayeClient = new FayeClient("/faye", rctMap);

});

...
        client = new Faye.Client(address);
var initSubscription = client.subscribe("/init", onInit);
initSubscription.callback(function() {
client.publish("/hello", "hello");

});

On the other end I have a subscriber to /hello which sends some initial
info on the "/init" channel from which the client unsubscribes. However,
this message usually does not arrive.

Relevant log parts are attached, but they don't make much sense to me. Can
you see if something's causing problems, or help me debug this issue
further?

Thanks,
Frank

  node logs.txt
3K Download

  successfull connect.txt
21K Download

  unsuccessfull connect.txt
4K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Coglan  
View profile  
 More options Aug 30 2012, 1:47 pm
From: James Coglan <jcog...@gmail.com>
Date: Thu, 30 Aug 2012 18:47:17 +0100
Local: Thurs, Aug 30 2012 1:47 pm
Subject: Re: Faye js client doesn't connect properly

On 30 August 2012 16:38, Frank Razenberg <zzatt...@gmail.com> wrote:

I don't understand what's going on here: you create two clients in the same
page -- are they attached to the same server? This will cause problems. As
I understand this code: the second client subscribes to /init, and when the
subscription is acknowledged, it publishes to /hello.

> Relevant log parts are attached, but they don't make much sense to me. Can
> you see if something's causing problems, or help me debug this issue
> further?

I have annotated the logs by splitting them into chunks and labelling each
chunk with what's going on, at a high level:
https://gist.github.com/3534634

Some observations:

The sections I've marked 'Connect cycle' are normal: a client publishes to
/meta/connect, and the server responds when there are new messages for the
client, or after a timeout, whichever is sooner. This is the long-polling
request. On a WebSocket connection, the client simply sends this message
periodically as a heartbeat for its clientId; the server can push messages
whenever it likes without a pending /meta/connect.

However you have set a very short timeout -- 2 seconds. This is why you're
seeing the connection cycle so frequently, and it may cause weird
behaviour. It effectively reduces Faye to a polling system. You should
still get every message you need, but you've got a lot of data going over
the wire that you don't need. Try a longer timeout, like 20 or 60 seconds.

I don't understand the difference between the successful and unsuccessful
client logs -- the latter is simply a truncated version of the former. This
is what the first one does:

* Handshakes
* Subscribes to /init
* Upgrades transport to WebSocket
* Publishes to /init
<-- Second one stops here
* Receives published message
* Unsubscribes from /init
* Subscribes to /update
* Subscribes to /delete
* Subscribes to /refresh
* Cycles /meta/connect every 2 seconds

The logs in the second case stop where I would expect to see the client
receiving the message to /init -- its subscription to that channel is
confirmed before the message is published. Is that the end of the logs?
Does it continue to cycle /meta/connect without receiving anything? Do you
see any errors, e.g. 'Unknown client'?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Coglan  
View profile  
 More options Aug 30 2012, 1:50 pm
From: James Coglan <jcog...@gmail.com>
Date: Thu, 30 Aug 2012 18:50:29 +0100
Local: Thurs, Aug 30 2012 1:50 pm
Subject: Re: Faye js client doesn't connect properly

On 30 August 2012 18:47, James Coglan <jcog...@gmail.com> wrote:

I should add: I'm not sure the logs correspond to the code, for example
there is no record of a publish to /hello in there. Did you mean
client.publish('/init', 'hello') ?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Coglan  
View profile  
 More options Aug 30 2012, 2:00 pm
From: James Coglan <jcog...@gmail.com>
Date: Thu, 30 Aug 2012 19:00:30 +0100
Local: Thurs, Aug 30 2012 2:00 pm
Subject: Re: Faye js client doesn't connect properly

On 30 August 2012 16:38, Frank Razenberg <zzatt...@gmail.com> wrote:

> The connect code is dirt-simple:
> var fayeClient;
> $(document).ready(function () {
> fayeClient = new FayeClient("/faye", rctMap);
> });
> ...
>         client = new Faye.Client(address);
> var initSubscription = client.subscribe("/init", onInit);
> initSubscription.callback(function() {
> client.publish("/hello", "hello");
> });

I've written a client script that just does this:

var client = new Faye.Client('http://localhost:8000/bayeux');
var initSubscription = client.subscribe("/init", function(m) {
console.log(m) });
initSubscription.callback(function() {
  client.publish("/init", "hello");

});

It prints "hello" every time I run the page, on a server with a 2-second
timeout.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Coglan  
View profile  
 More options Aug 30 2012, 2:05 pm
From: James Coglan <jcog...@gmail.com>
Date: Thu, 30 Aug 2012 19:05:17 +0100
Local: Thurs, Aug 30 2012 2:05 pm
Subject: Re: Faye js client doesn't connect properly

On 30 August 2012 18:47, James Coglan <jcog...@gmail.com> wrote:

> I have annotated the logs by splitting them into chunks and labelling each
> chunk with what's going on, at a high level:
> https://gist.github.com/3534634

One thing I just realized: your server logs
https://gist.github.com/3534634#file_server_logs.js do not show message #4.
They show:

1. Handshake
2. Subscribe
3. Connect
5. Connect
6. Connect
7. Connect

In the client logs https://gist.github.com/3534634#file_successful_client.js,
the message published to /init is #4. Seems like your code isn't reaching
the client.publish() line, or that message is not being received by the
server. Might just be coincidence, though.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Frank Razenberg  
View profile  
 More options Sep 1 2012, 4:32 am
From: Frank Razenberg <fr...@zzattack.org>
Date: Sat, 1 Sep 2012 01:32:18 -0700 (PDT)
Local: Sat, Sep 1 2012 4:32 am
Subject: Re: Faye js client doesn't connect properly

In the client logs https://gist.github.com/3534634#file_successful_client.js,

> the message published to /init is #4. Seems like your code isn't reaching
> the client.publish() line, or that message is not being received by the
> server. Might just be coincidence, though.

Hi James,
Thanks for your thorough reply and apologies for my late reply. I dug into
this a bit deeper and added some better logs; one where everything goes as
expected, and one where some things seems to fail.

> I don't understand what's going on here: you create two clients in the

same page
What I called FayeClient (mind the lack of dot) is a small wrapper which
contains the subscription/message handling. This class has a Faye.Client
member (mind the dot) - so there's really just one connection to the server.

> The logs in the second case stop where I would expect to see the client

receiving the message to /init -- its subscription to that channel is
confirmed before the message is published. Is that the end of the
logs? Does it continue to cycle /meta/connect without receiving anything?
Do you see any errors, e.g. 'Unknown client'?
Yes, that was the end of the log. The /hello" message does not arrive at
any of the other clients - but it may have been the case that the C# client
did not connect properly either.

For each scenario I think randomly occurs I've added some logs:
- logs_expected.txt contain the server logs of a successfull connect by the
C# client. Then I let the JS client connect, and message are exchanged as
expected.
- logs_c#_unexpected_client.txt contains the server-side logs of a session
where the C# client does not connect properly
- logs_ja_fail.txt contains server-side logs where the C# client connects
and subscribes as expected, but the JS client does not.

The observed behavior seems very random, about 1/3 times everything goes as
expected. The C# client not connecting properly (about 1 of 5 times) is
more rare than the JS client not connecting properly (about 2 out of 3
times). I hope you can make anything out of this :)

Kind regards,
Frank

  logs_C#_unknown_client.txt
2K Download

  logs_expected.txt
8K Download

  logs_js_fail.txt
9K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Coglan  
View profile  
 More options Sep 8 2012, 10:55 am
From: James Coglan <jcog...@gmail.com>
Date: Sat, 8 Sep 2012 16:55:05 +0200
Local: Sat, Sep 8 2012 10:55 am
Subject: Re: Faye js client doesn't connect properly

On 1 September 2012 10:32, Frank Razenberg <fr...@zzattack.org> wrote:

> The observed behavior seems very random, about 1/3 times everything goes
> as expected. The C# client not connecting properly (about 1 of 5 times) is
> more rare than the JS client not connecting properly (about 2 out of 3
> times). I hope you can make anything out of this :)

I think the C# client is overloading the server by misbehaving -- it's very
weird that the JS client does not get a reply when it publishes to /hello.
These logs are suspicious:

2012-09-01 09:47:10 [INFO] [Faye.Server] Processing messages:
[{"channel":"/meta/connect","connectionType":"long-polling","id":"3","clien tId":"1u0pg2k03kr8m403srfiz1g4yqa5"}]
(local: false)
2012-09-01 09:47:10 [INFO] [Faye.Server] Handling message:
{"channel":"/meta/connect","connectionType":"long-polling","id":"3","client Id":"1u0pg2k03kr8m403srfiz1g4yqa5"}
(local: false)
2012-09-01 09:47:10 [INFO] [Faye.Server] Processing messages:
[{"channel":"/meta/connect","connectionType":"long-polling","id":"3","clien tId":"1u0pg2k03kr8m403srfiz1g4yqa5"}]
(local: false)
2012-09-01 09:47:10 [INFO] [Faye.Server] Handling message:
{"channel":"/meta/connect","connectionType":"long-polling","id":"3","client Id":"1u0pg2k03kr8m403srfiz1g4yqa5"}
(local: false)

This shows the C# client polling /meta/connect twice in one second, without
getting a reply. The timeout seems to be set to 120, and the client should
wait until it gets a /meta/connect reply before polling again.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Coglan  
View profile  
 More options Sep 8 2012, 11:23 am
From: James Coglan <jcog...@gmail.com>
Date: Sat, 8 Sep 2012 17:23:06 +0200
Local: Sat, Sep 8 2012 11:23 am
Subject: Re: Faye js client doesn't connect properly

On 8 September 2012 16:55, James Coglan <jcog...@gmail.com> wrote:

> On 1 September 2012 10:32, Frank Razenberg <fr...@zzattack.org> wrote:

>> The observed behavior seems very random, about 1/3 times everything goes
>> as expected. The C# client not connecting properly (about 1 of 5 times) is
>> more rare than the JS client not connecting properly (about 2 out of 3
>> times). I hope you can make anything out of this :)

> I think the C# client is overloading the server by misbehaving -- it's
> very weird that the JS client does not get a reply when it publishes to
> /hello. These logs are suspicious:

Would also like to see debug logs for the server. There's no record of the
server receiving the /hello message from the JS client,  but I'm not sure
if that's accidental.

You should also check which transport is in use when publishing to /hello
-- see client._transport.connectionType. You'll need to use the unminified
client from /faye/faye-browser.js for this to work.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »