[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jetty-users] Re: Jetty websocket almost works with Flash-based websocket clients
|
My bad, I now see there is an open enhancement request + patch for this already:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=298718I'll go vote there.
On Wed, Feb 10, 2010 at 12:17 AM, Jeoff Wilks
<jeoffwilks@xxxxxxxxx> wrote:
I'm trying to get jetty websockets to talk to this Flash-based web-socket-js library (which retrofits old browsers with websocket support):
http://github.com/gimite/web-socket-js
I can't get it to work, because the Flash client is sending a socket-policy-request that the server doesn't understand (HttpException 400 thrown at HttpParser.java:352). In the ruby-based sample websocket server that ships with the flash client, and also in this code from a nodejs websocket server [1], the Flash policy-file-request is detected and served automatically. Are there any plans for Jetty to support automatic flash policy file serving so that Flash-based clients can seamlessly connect?
The alternative is to set up a Flash policy file server on port 843. There are perl scripts in the wild that do this pretty easily, but I was hoping to not have to manage a separate process for such a simple thing. I suppose I could add a servlet that opens up its own rogue socket listener on port 843, but it seems like a reasonable thing to support by default through the standard http port, since Flash is likely to be the bridge to websockets for a while yet...
[1] from http://github.com/Guille/node.websocket.js/blob/master/websocket.js#L170
Basically, a special case for handling
if (headers.length && headers[0].match(/<policy-file-request.*>/)) {
// allows Flash based WebSocket implementation to connect.
this.log('Flash policy file request');
this._serveFlashPolicy();
return false;
}
...
Connection.prototype._serveFlashPolicy = function(){
var origins = this.server.options.origins;
if (!tools.isArray(origins)) {
origins = [origins];
}
this.socket.send('<?xml version="1.0"?>\n');
this.socket.send('<cross-domain-policy>\n');
for (var i = 0, l = origins.length; i < l; i++){
this.socket.send(' <allow-access-from domain="' + origins[i] + '" to-ports="' + this.server.options.port + '"/>\n');
}
this.socket.send('</cross-domain-policy>\n');
this.socket.close();
};