Cross-domain WebSocket?

248 views
Skip to first unread message

James Coglan

unread,
Jul 5, 2010, 4:38:40 PM7/5/10
to CometD list
After the announcement earlier about 2.0's imminent release, I'm giving it a run using the Faye client[1] which I've been trying to make compatible with CometD. I'd got it working under 1.0, but now it doesn't work in Chrome. My WebSocket transport is not firing either its onopen() or onerror() methods, so I'm not sure what's going on. Scanning the CometD source I see something called WebSocketCrossOriginFilter -- does CometD's WebSocket backend not support cross-domain communication, and if so is there a way of signalling that through the protocol so my client doesn't assume it can use the WebSocket transport to talk to CometD?

Simone Bordet

unread,
Jul 5, 2010, 4:51:11 PM7/5/10
to cometd...@googlegroups.com
Hi,

On Mon, Jul 5, 2010 at 22:38, James Coglan <jco...@gmail.com> wrote:
> After the announcement earlier about 2.0's imminent release, I'm giving it a
> run using the Faye client[1] which I've been trying to make compatible with
> CometD. I'd got it working under 1.0, but now it doesn't work in Chrome. My
> WebSocket transport is not firing either its onopen() or onerror() methods,
> so I'm not sure what's going on.

Which Chrome version ?
There is a bug in Chrome that prevents WebSocket to work if the host
is "localhost".
See http://bugs.cometd.org/browse/COMETD-135.

> Scanning the CometD source I see something
> called WebSocketCrossOriginFilter -- does CometD's WebSocket backend not
> support cross-domain communication, and if so is there a way of signalling
> that through the protocol so my client doesn't assume it can use the
> WebSocket transport to talk to CometD?

WebSocketCrossOriginFilter is just a workaround for silly WebSocket
protocol restrictions.
It is only needed with Jetty 7.1.3 or earlier, since we workaround it
in Jetty 7.1.4.
We're removing WebSocketCrossOriginFilter soon, since latest CometD
trunks for 1.x and 2.x are updated to at least Jetty 7.1.4.

Let us know what you find.

Simon
--
http://bordet.blogspot.com
---
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless. Victoria Livschitz

James Coglan

unread,
Jul 5, 2010, 5:01:18 PM7/5/10
to cometd...@googlegroups.com
On 5 July 2010 21:51, Simone Bordet <simone...@gmail.com> wrote:
Hi,

On Mon, Jul 5, 2010 at 22:38, James Coglan <jco...@gmail.com> wrote:
> After the announcement earlier about 2.0's imminent release, I'm giving it a
> run using the Faye client[1] which I've been trying to make compatible with
> CometD. I'd got it working under 1.0, but now it doesn't work in Chrome. My
> WebSocket transport is not firing either its onopen() or onerror() methods,
> so I'm not sure what's going on.

Which Chrome version ?
There is a bug in Chrome that prevents WebSocket to work if the host
is "localhost".
See http://bugs.cometd.org/browse/COMETD-135.

Ah, yes. I should have remembered from my own testing. Setting the host in my client app to 127.0.0.1 works a treat! It does work cross-domain, since my page is on http://localhost:8000/ and it's connecting to CometD at http://127.0.0.1:8080/cometd.
 
Reply all
Reply to author
Forward
0 new messages