Quantcast

atmosphere behind apache and browser issues

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

atmosphere behind apache and browser issues

Moritz Kleine
Hi all, I'm pretty new to atmosphere, but I have successfully derived my own application from chat-jersey example (atmosphere 1.1.0.beta3). It's running fine in jetty and tomcat but now I'm experiencing two problems:

1. Chrome and Firefox browser tabs don't close anymore when the atmosphere connection was opened - they close only when I shut down the server - any ideas what might cause this strange behavior?
2. When I put apache in front of tomcat (HTTPS and internal URL rewriting) atmosphere doesn't seem to connect successfully. All I get is this:

  1. Uncaught TypeError: Cannot call method 'concat' of null jquery.atmosphere.js:375
    1. (anonymous function)application.js:50
    2. (anonymous function)

 any ideas how to solve these issues?

the contents of my application.js follows below.

Cheers,
Moritz

(function ($, jQuery) {
  var logged = false;
  var socket = $.atmosphere;
  var headers = {}; // maye later
  var request = { url:'atmosphere/event',
    contentType:"application/json",
    logLevel:'debug',
    transport:'websocket',
    fallbackTransport:'long-polling',
    shared:true, // share websocket connection among tabs
    headers:headers
  };


  request.onOpen = function (response) {
    console.log('Atmosphere connected using ' + response.transport);
    console.log('Listening to repository events');
  };

  request.onMessage = function (response) {
    var message = response.responseBody;
    try {
      var json = jQuery.parseJSON(message);
    } catch (e) {
      console.log('This doesn\'t look like a valid JSON: ', message.data);
      return;
    }

    console.log('received events: ' + JSON.stringify(json));
    json.every(function (item) {
      var remoteBean = beanCache[item];
      if (remoteBean) {
        remoteBean.invalidate();
      } else {
        console.log("there's a new remote bean at URI", item);
      }
    })
  };

  request.onClose = function (response) {
    logged = false;
    console.log('closed');
  };

  request.onError = function (response) {
    console.error('Sorry, but there\'s some problem with your '
            + 'socket or the server is down');
  };

  var subSocket = socket.subscribe(request);

  // expose objects
  var pkg = window.mypgg;
  pkg.atmosphere = socket;
  pkg.subscribed = subSocket;
  pkg.request = request;

  console.log("initialized atmosphere request", request, "on socket", socket);
})($, jQuery);


--
You received this message because you are subscribed to the Google Groups "The Atmosphere Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: atmosphere behind apache and browser issues

Jeanfrancois Arcand
Salut,

On 13-02-22 6:54 AM, [hidden email] wrote:
Hi all, I'm pretty new to atmosphere, but I have successfully derived my own application from chat-jersey example (atmosphere 1.1.0.beta3). It's running fine in jetty and tomcat but now I'm experiencing two problems:

1. Chrome and Firefox browser tabs don't close anymore when the atmosphere connection was opened - they close only when I shut down the server - any ideas what might cause this strange behavior?
2. When I put apache in front of tomcat (HTTPS and internal URL rewriting) atmosphere doesn't seem to connect successfully. All I get is this:

  1. Uncaught TypeError: Cannot call method 'concat' of null jquery.atmosphere.js:375
    1. (anonymous function)application.js:50
    2. (anonymous function)

 any ideas how to solve these issues?
Can you remove shared:true and see if you still get the issue above? Any reason to not use 1.0.11 instead?

A+

-- Jeanfrancois




the contents of my application.js follows below.

Cheers,
Moritz

(function ($, jQuery) {
  var logged = false;
  var socket = $.atmosphere;
  var headers = {}; // maye later
  var request = { url:'atmosphere/event',
    contentType:"application/json",
    logLevel:'debug',
    transport:'websocket',
    fallbackTransport:'long-polling',
    shared:true, // share websocket connection among tabs
    headers:headers
  };


  request.onOpen = function (response) {
    console.log('Atmosphere connected using ' + response.transport);
    console.log('Listening to repository events');
  };

  request.onMessage = function (response) {
    var message = response.responseBody;
    try {
      var json = jQuery.parseJSON(message);
    } catch (e) {
      console.log('This doesn\'t look like a valid JSON: ', message.data);
      return;
    }

    console.log('received events: ' + JSON.stringify(json));
    json.every(function (item) {
      var remoteBean = beanCache[item];
      if (remoteBean) {
        remoteBean.invalidate();
      } else {
        console.log("there's a new remote bean at URI", item);
      }
    })
  };

  request.onClose = function (response) {
    logged = false;
    console.log('closed');
  };

  request.onError = function (response) {
    console.error('Sorry, but there\'s some problem with your '
            + 'socket or the server is down');
  };

  var subSocket = socket.subscribe(request);

  // expose objects
  var pkg = window.mypgg;
  pkg.atmosphere = socket;
  pkg.subscribed = subSocket;
  pkg.request = request;

  console.log("initialized atmosphere request", request, "on socket", socket);
})($, jQuery);


--
You received this message because you are subscribed to the Google Groups "The Atmosphere Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "The Atmosphere Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: atmosphere behind apache and browser issues

Moritz Kleine
In reply to this post by Moritz Kleine
Hi Jeanfrancois, thanks for your help. I don't set shared anymore (I don't need it anyway) and gave 1.0.11 a try. The current state is:

1. Tabs close as expected and everything works great with tomcat and jetty
2. My Apache Setup works better than before

Unfortunately I get some errors in my apache log (apache 2.2.15-15.el6.centos.1).

[Mon Feb 25 09:47:14 2013] [error] (70007)The timeout specified has expired: ajp_ilink_receive() can't receive header

This seems to be related to this message that I get in Chrome (version 24.0.1312.57):

Error during WebSocket handshake: 'Connection' header value is not 'Upgrade'

then sometimes it shows me this in console:

That doesn't look too good but it's working anyway (with these errors when connecting to apache over https, without any errors when connecting to tomcat not using https).

It's a little more complicated with Firefox I think.

Firefox 10.0.12 tells me

"NetworkError: 501 Not Implemented - https://studio.media.opti-demo.coremedia.com/studio/atmosphere/event?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=1.1.0.beta4&X-Atmosphere-Transport=websocket&X-Cache-Date=0&Content-Type=application/json&X-atmo-protocol=true"

Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent).
jquery...here.js (Zeile 2528)
Websocket closed, wasClean: false
jquery...here.js (Zeile 2528)
Websocket failed. Downgrading to Comet and resending

then it works just fine. It makes no difference whether I'm connecting with tomcat (http) or apache (https).

When I'm connecting to apache (https) with Firefox 19.0 I get this output:

net.ja...sses.js (line 219)
jquery...here.js (line 2528)
application.js (line 16)
application.js (line 17)
jquery...here.js (line 2528)
jquery...here.js (line 2528)
jquery...here.js (line 2528)

and then finally

--
You received this message because you are subscribed to the Google Groups "The Atmosphere Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: atmosphere behind apache and browser issues

Moritz Kleine
Update: The Chrome -> Apache setup stops working after a minute or so.

--
You received this message because you are subscribed to the Google Groups "The Atmosphere Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: atmosphere behind apache and browser issues

Jeanfrancois Arcand
In reply to this post by Moritz Kleine
Salut,

really difficult to help...for the first error, since Apache doesn't support WebSocket I suspect this is why the browser receive that error.

Chrome: that's expected, it fallback to your fallbackTransport. What's the value set?
Firefox: that's seems to be a bug, but really hard to say without a test case. It seems websocket keep reconnecting without falling back. Can you make your app available over the internet? That way I can debug why the script fail to fallback.

A+

-- Jeanfrancois



On 13-02-25 4:45 AM, Moritz Kleine wrote:
Hi Jeanfrancois, thanks for your help. I don't set shared anymore (I don't need it anyway) and gave 1.0.11 a try. The current state is:

1. Tabs close as expected and everything works great with tomcat and jetty
2. My Apache Setup works better than before

Unfortunately I get some errors in my apache log (apache 2.2.15-15.el6.centos.1).

[Mon Feb 25 09:47:14 2013] [error] (70007)The timeout specified has expired: ajp_ilink_receive() can't receive header

This seems to be related to this message that I get in Chrome (version 24.0.1312.57):

Error during WebSocket handshake: 'Connection' header value is not 'Upgrade'

then sometimes it shows me this in console:

That doesn't look too good but it's working anyway (with these errors when connecting to apache over https, without any errors when connecting to tomcat not using https).

It's a little more complicated with Firefox I think.

Firefox 10.0.12 tells me


Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent).
jquery...here.js (Zeile 2528)
Websocket closed, wasClean: false
jquery...here.js (Zeile 2528)
Websocket failed. Downgrading to Comet and resending

then it works just fine. It makes no difference whether I'm connecting with tomcat (http) or apache (https).

When I'm connecting to apache (https) with Firefox 19.0 I get this output:

net.ja...sses.js (line 219)
jquery...here.js (line 2528)
application.js (line 16)
application.js (line 17)
jquery...here.js (line 2528)
jquery...here.js (line 2528)
jquery...here.js (line 2528)

and then finally

--
You received this message because you are subscribed to the Google Groups "The Atmosphere Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "The Atmosphere Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: atmosphere behind apache and browser issues

Mark Thomas
In reply to this post by Moritz Kleine
You cannot use WebSockets when proxying through Apache as Apache does not support WebSockets.  You can make Atmosphere more stable by disabling websockets via the web.xml servlet init param org.atmosphere.useWebSocket (set to false).  Atmosphere is supposed to degrade gracefully; however, as you've experienced, it's still very browser+server combo dependent on how well that works.  For the most part it does an excellent job but there are certain cases where it gets flaky.  If you're going to stick with Apache then disable websocket support.  If you want websockets then consider https://github.com/dotcloud/hipache or HAProxy

On Friday, February 22, 2013 5:54:49 AM UTC-6, Moritz Kleine wrote:
Hi all, I'm pretty new to atmosphere, but I have successfully derived my own application from chat-jersey example (atmosphere 1.1.0.beta3). It's running fine in jetty and tomcat but now I'm experiencing two problems:

1. Chrome and Firefox browser tabs don't close anymore when the atmosphere connection was opened - they close only when I shut down the server - any ideas what might cause this strange behavior?
2. When I put apache in front of tomcat (HTTPS and internal URL rewriting) atmosphere doesn't seem to connect successfully. All I get is this:

  1. Uncaught TypeError: Cannot call method 'concat' of null jquery.atmosphere.js:375
    1. (anonymous function)application.js:50
    2. (anonymous function)

 any ideas how to solve these issues?

the contents of my application.js follows below.

Cheers,
Moritz

(function ($, jQuery) {
  var logged = false;
  var socket = $.atmosphere;
  var headers = {}; // maye later
  var request = { url:'atmosphere/event',
    contentType:"application/json",
    logLevel:'debug',
    transport:'websocket',
    fallbackTransport:'long-polling',
    shared:true, // share websocket connection among tabs
    headers:headers
  };


  request.onOpen = function (response) {
    console.log('Atmosphere connected using ' + response.transport);
    console.log('Listening to repository events');
  };

  request.onMessage = function (response) {
    var message = response.responseBody;
    try {
      var json = jQuery.parseJSON(message);
    } catch (e) {
      console.log('This doesn\'t look like a valid JSON: ', message.data);
      return;
    }

    console.log('received events: ' + JSON.stringify(json));
    json.every(function (item) {
      var remoteBean = beanCache[item];
      if (remoteBean) {
        remoteBean.invalidate();
      } else {
        console.log("there's a new remote bean at URI", item);
      }
    })
  };

  request.onClose = function (response) {
    logged = false;
    console.log('closed');
  };

  request.onError = function (response) {
    console.error('Sorry, but there\'s some problem with your '
            + 'socket or the server is down');
  };

  var subSocket = socket.subscribe(request);

  // expose objects
  var pkg = window.mypgg;
  pkg.atmosphere = socket;
  pkg.subscribed = subSocket;
  pkg.request = request;

  console.log("initialized atmosphere request", request, "on socket", socket);
})($, jQuery);


--
You received this message because you are subscribed to the Google Groups "The Atmosphere Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: atmosphere behind apache and browser issues

Jeanfrancois Arcand
Salut Mark,

On 13-02-25 11:21 AM, Mark Thomas wrote:
You cannot use WebSockets when proxying through Apache as Apache does not support WebSockets.  You can make Atmosphere more stable by disabling websockets via the web.xml servlet init param org.atmosphere.useWebSocket (set to false).  Atmosphere is supposed to degrade gracefully; however, as you've experienced, it's still very browser+server combo dependent on how well that works.  For the most part it does an excellent job but there are certain cases where it gets flaky.
Any scenarios you can share? I would like to fix them :-)

Thanks!

-- Jeanfrancois


 If you're going to stick with Apache then disable websocket support.  If you want websockets then consider https://github.com/dotcloud/hipache or HAProxy

On Friday, February 22, 2013 5:54:49 AM UTC-6, Moritz Kleine wrote:
Hi all, I'm pretty new to atmosphere, but I have successfully derived my own application from chat-jersey example (atmosphere 1.1.0.beta3). It's running fine in jetty and tomcat but now I'm experiencing two problems:

1. Chrome and Firefox browser tabs don't close anymore when the atmosphere connection was opened - they close only when I shut down the server - any ideas what might cause this strange behavior?
2. When I put apache in front of tomcat (HTTPS and internal URL rewriting) atmosphere doesn't seem to connect successfully. All I get is this:

  1. Uncaught TypeError: Cannot call method 'concat' of null jquery.atmosphere.js:375
    1. (anonymous function)application.js:50
    2. (anonymous function)

 any ideas how to solve these issues?

the contents of my application.js follows below.

Cheers,
Moritz

(function ($, jQuery) {
  var logged = false;
  var socket = $.atmosphere;
  var headers = {}; // maye later
  var request = { url:'atmosphere/event',
    contentType:"application/json",
    logLevel:'debug',
    transport:'websocket',
    fallbackTransport:'long-polling',
    shared:true, // share websocket connection among tabs
    headers:headers
  };


  request.onOpen = function (response) {
    console.log('Atmosphere connected using ' + response.transport);
    console.log('Listening to repository events');
  };

  request.onMessage = function (response) {
    var message = response.responseBody;
    try {
      var json = jQuery.parseJSON(message);
    } catch (e) {
      console.log('This doesn\'t look like a valid JSON: ', message.data);
      return;
    }

    console.log('received events: ' + JSON.stringify(json));
    json.every(function (item) {
      var remoteBean = beanCache[item];
      if (remoteBean) {
        remoteBean.invalidate();
      } else {
        console.log("there's a new remote bean at URI", item);
      }
    })
  };

  request.onClose = function (response) {
    logged = false;
    console.log('closed');
  };

  request.onError = function (response) {
    console.error('Sorry, but there\'s some problem with your '
            + 'socket or the server is down');
  };

  var subSocket = socket.subscribe(request);

  // expose objects
  var pkg = window.mypgg;
  pkg.atmosphere = socket;
  pkg.subscribed = subSocket;
  pkg.request = request;

  console.log("initialized atmosphere request", request, "on socket", socket);
})($, jQuery);


--
You received this message because you are subscribed to the Google Groups "The Atmosphere Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "The Atmosphere Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: atmosphere behind apache and browser issues

Mark Thomas
I've had problems with session support on glassfish and in general with IE (surprise, surprise) using XDomainTransport in the past.  I'm still on 1.0.x codebase so these might be better in 1.1.x.  More generally though, there is an inherent balancing act with certain servers, transports, and Atmosphere configs that a newcomer is most likely not aware of.  For example, people using tomcat with a servlet 3 streaming transport might set an atmosphere resource timeout of 30 seconds and get confused as to why their connection dies every ten seconds.  unless they knew about default value of 10 sec for the asyncTimeout attribute of the Connector element in server.xml (which is not present in the server.xml shipped in the tomcat tarball) they'd be at a loss as to what the problem was and most likely blame Atmosphere.  so it's not really actual 'flakiness' per se, but for the novice or uninformed it could easily appear that way.

On Monday, February 25, 2013 12:53:05 PM UTC-6, jfarcand wrote:
Salut Mark,

On 13-02-25 11:21 AM, Mark Thomas wrote:
You cannot use WebSockets when proxying through Apache as Apache does not support WebSockets.  You can make Atmosphere more stable by disabling websockets via the web.xml servlet init param org.atmosphere.useWebSocket (set to false).  Atmosphere is supposed to degrade gracefully; however, as you've experienced, it's still very browser+server combo dependent on how well that works.  For the most part it does an excellent job but there are certain cases where it gets flaky.
Any scenarios you can share? I would like to fix them :-)

Thanks!

-- Jeanfrancois


 If you're going to stick with Apache then disable websocket support.  If you want websockets then consider https://github.com/dotcloud/hipache or HAProxy

On Friday, February 22, 2013 5:54:49 AM UTC-6, Moritz Kleine wrote:
Hi all, I'm pretty new to atmosphere, but I have successfully derived my own application from chat-jersey example (atmosphere 1.1.0.beta3). It's running fine in jetty and tomcat but now I'm experiencing two problems:

1. Chrome and Firefox browser tabs don't close anymore when the atmosphere connection was opened - they close only when I shut down the server - any ideas what might cause this strange behavior?
2. When I put apache in front of tomcat (HTTPS and internal URL rewriting) atmosphere doesn't seem to connect successfully. All I get is this:

  1. Uncaught TypeError: Cannot call method 'concat' of null jquery.atmosphere.js:375
    1. (anonymous function)application.js:50
    2. (anonymous function)

 any ideas how to solve these issues?

the contents of my application.js follows below.

Cheers,
Moritz

(function ($, jQuery) {
  var logged = false;
  var socket = $.atmosphere;
  var headers = {}; // maye later
  var request = { url:'atmosphere/event',
    contentType:"application/json",
    logLevel:'debug',
    transport:'websocket',
    fallbackTransport:'long-polling',
    shared:true, // share websocket connection among tabs
    headers:headers
  };


  request.onOpen = function (response) {
    console.log('Atmosphere connected using ' + response.transport);
    console.log('Listening to repository events');
  };

  request.onMessage = function (response) {
    var message = response.responseBody;
    try {
      var json = jQuery.parseJSON(message);
    } catch (e) {
      console.log('This doesn\'t look like a valid JSON: ', message.data);
      return;
    }

    console.log('received events: ' + JSON.stringify(json));
    json.every(function (item) {
      var remoteBean = beanCache[item];
      if (remoteBean) {
        remoteBean.invalidate();
      } else {
        console.log("there's a new remote bean at URI", item);
      }
    })
  };

  request.onClose = function (response) {
    logged = false;
    console.log('closed');
  };

  request.onError = function (response) {
    console.error('Sorry, but there\'s some problem with your '
            + 'socket or the server is down');
  };

  var subSocket = socket.subscribe(request);

  // expose objects
  var pkg = window.mypgg;
  pkg.atmosphere = socket;
  pkg.subscribed = subSocket;
  pkg.request = request;

  console.log("initialized atmosphere request", request, "on socket", socket);
})($, jQuery);


--
You received this message because you are subscribed to the Google Groups "The Atmosphere Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="IJV1Zl0vmxUJ">atmosphere-framework+unsubscribe@....
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "The Atmosphere Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Loading...