0

I am using private_pub which is a wrapper for faye

https://github.com/ryanb/private_pub

I wan't to disable websockets on the client side, so faye will fall back to polling, because my production environment doesn't support websockets.

It is advised to do so on the faye website:

For some applications you may need to exclude some transports from use. For example you may know your deployment environment cannot support WebSockets, or you have reasons to stick to polling. In such situations you can disable a transport like so:

client.disable('websocket');

http://faye.jcoglan.com/browser.html

I attempt to modify the private_pub.js code to disable websockets upon creation:

self.fayeClient = new Faye.Client(self.subscriptions.server);
self.fayeClient.disable('websocket'); // my modification

But I get this error: TypeError: Object # has no method 'disable'

I am pretty certain that the 'client' on the site's example is the same type as my client, because earlier on the site this code is shown: var client = new Faye.Client('http://localhost:8000/faye'); , just like how the self.fayeClient in my code is created.

Am I not understanding something about the example in the site? Or how should I disable the websockets so that my faye client will use polling instead of websockets?

Vall3y
  • 1,181
  • 8
  • 18

2 Answers2

1

It appears this solves the problem: Faye.Transport.WebSocket.isUsable = function(_,c) { c(false) }. Found the solution here: http://groups.google.com/group/faye-users/browse_thread/thread/14447dae9f75afab

Vall3y
  • 1,181
  • 8
  • 18
0

Have you tried just

client.disable('websocket'); 

The var client is equal to the faye client, but you use self.fayeClient as the object

PitaJ
  • 12,969
  • 6
  • 36
  • 55