Disable WebSockets?

731 views
Skip to first unread message

Bruno Michel

unread,
Aug 30, 2011, 7:04:26 AM8/30/11
to Faye users
Hello,

I'm using Faye on one project behind nginx. And so, the WebSocket
can't be used as nginx doesn't support them for the moment. I'd like
to disable the WebSocket transport to avoid the error message in
firebug. Is it possible?

After reading the docs, it doesn't seem to be the case. Should I
propose a patch to add an option on the creation of Faye.Client to
specify which transports to use? Or just one to disable WebSockets?

++
Bruno

James Coglan

unread,
Aug 30, 2011, 7:07:27 AM8/30/11
to faye-...@googlegroups.com
An API to limit which transports to use might be useful, although we'll need to do it very carefully since some transports are 'special' -- a client can assume the server supports them in order to make the initial handshake and discover the server's other supported transports.

If you want to disable WebSockets for now, you can patch the transport like this:

Faye.Transport.WebSocket.isUsable = function(_,c) { c(false) }

EyePulp

unread,
Aug 30, 2011, 5:38:37 PM8/30/11
to Faye users
I get this in FF6 very reliably - this workaround to shut off
websockets did just the trick. Thanks!

On Aug 30, 6:07 am, James Coglan <jcog...@gmail.com> wrote:

Bruno Michel

unread,
Aug 31, 2011, 12:30:34 PM8/31/11
to Faye users
Thanks for the workaround.

I'll see if I understand the transports selection and the 'special'
ones and, if so, I'll try to submit a patch.

++
Bruno

upisdown

unread,
Feb 7, 2013, 7:16:37 PM2/7/13
to faye-...@googlegroups.com
Where do we put this? in faye.ru ?

I used to use client.disable("websocket"); 

on the client side but it doesnt seem to be working anymore.

James Coglan

unread,
Feb 7, 2013, 7:23:41 PM2/7/13
to faye-...@googlegroups.com
On 8 February 2013 00:16, upisdown <trim...@gmail.com> wrote:
I used to use client.disable("websocket"); 

on the client side but it doesnt seem to be working anymore.

This is currently broken but will be fixed in 0.8.9. The original workaround of patching isUsable() should work until then. 

upisdown

unread,
Feb 8, 2013, 12:21:03 AM2/8/13
to faye-...@googlegroups.com
Okay so I'm not going crazy. But I was forced to learn how to setup HAproxy
so all for the best.

I apologize if I seem dense but where do I apply the patch? I tried putting
the line below in my faye.ru but it threw and error.

Faye.Transport.WebSocket.**isUsable = function(_,c) { c(false) }

James Coglan

unread,
Feb 8, 2013, 4:35:24 AM2/8/13
to faye-...@googlegroups.com
On 8 February 2013 05:21, upisdown <trim...@gmail.com> wrote:
I apologize if I seem dense but where do I apply the patch? I tried putting
the line below in my faye.ru but it threw and error.

Faye.Transport.WebSocket.isUsable = function(_,c) { c(false) }

This goes in your JavaScript. 

upisdown

unread,
Feb 8, 2013, 4:51:20 AM2/8/13
to faye-...@googlegroups.com
Any leads on why I would get this error after adding the before mentioned line after the below line in my javascript? 

var faye = new Faye.Client('https://i.hoped.so/faye');
Faye.Transport.WebSocket.isUsable = function(_,c) { c(false) };

  1. Uncaught TypeError: string is not a function i.hoped.so:82
    1. Faye.Transport.WebSocket.isUsablei.hoped.so:82
    2. (anonymous function)faye.js:1
    3. Faye.extend.asyncEachfaye.js:1
    4. Faye.Transport.Faye.extend.getfaye.js:1
    5. Faye.Client.Faye.Class._Afaye.js:1
    6. (anonymous function)faye.js:1
    7. (anonymous function)faye.js:1
    8. Faye.Extensible.pipeThroughExtensionsfaye.js:1
    9. Faye.Client.Faye.Class.receiveMessagefaye.js:1
    10. Faye.Transport.Faye.extend.Faye.Class.receivefaye.js:1
    11. j.onreadystatechange

upisdown

unread,
Feb 8, 2013, 4:55:37 AM2/8/13
to faye-...@googlegroups.com
Oh I tried it above too and get the same error.

James Coglan

unread,
Feb 8, 2013, 5:10:58 AM2/8/13
to faye-...@googlegroups.com
On 8 February 2013 09:51, upisdown <trim...@gmail.com> wrote:
Any leads on why I would get this error after adding the before mentioned line after the below line in my javascript? 

var faye = new Faye.Client('https://i.hoped.so/faye');
Faye.Transport.WebSocket.isUsable = function(_,c) { c(false) };

Oh, it takes an additional param these days:

Faye.Transport.WebSocket.isUsable = function($, _, c) { c(false) }; 
Reply all
Reply to author
Forward
0 new messages