Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Can't receive subscribed real-time messages under tomcat

    My very simple test messaging system works perfectly fine in "development" mode when using the built-in "jetty" j2ee server for GWT under Eclipse. I can send and receive messages fine. When I build and run the code on tomcat, though, I can send messages (no errors) but I don't ever receive them (still no errors). I tried switching to the ActiveMQ enterprise messaging system (and followed the documentation described in the link https://isomorphic.atlassian.net/wiki/plugins/servlet/mobile#content/view/525029), but it's the same problem: no errors with either sending or attempt to receive, but I simply don't receive any messages. My Tomcat installation is pretty vanilla. Here's my test code to send:

    Code:
    package com.smartgwt.sample.client.components;
    
    import com.smartgwt.client.rpc.MessagingCallback;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.Button;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.sample.client.WnDialog;
    import com.smartgwt.sample.client.util.SubscriberUtil;
    
    public class MessageTestWindow extends WnDialog {
    
    	private DynamicForm dynamicForm;
    	private TextItem textItem;
    	private Button subscribeBtn;
    	private Button sendBtn;
    	private MessagingCallback messagingCallback;
    	private final String CHANNEL = "testChannel";
    
    	public MessageTestWindow() {
    		super(350, 250, "Message Test", "icons/Delete.png");
    		initialize();
    		initClickHandler();
    	}
    
    	private void initialize() {
    		this.subscribeBtn = new Button("Subscribe");
    		this.sendBtn = new Button("Send");
    		this.dynamicForm = new DynamicForm();
    		this.textItem = new TextItem("SendText");
    		this.textItem.setTitle("Send Text");
    		this.dynamicForm.setItems(textItem);
    
    		vsRoot.addMember(subscribeBtn);
    		vsRoot.addMember(dynamicForm);
    		vsRoot.addMember(sendBtn);
    
    		this.messagingCallback = new MessagingCallback() {
    
    			@Override
    			public void execute(Object data) {
    				SC.say("Message received: " + data);
    			}
    		};
    	}
    
    	private void initClickHandler() {
    
    		subscribeBtn.addClickHandler(new ClickHandler() {
    
    			@Override
    			public void onClick(ClickEvent event) {
    				SubscriberUtil.subscribeToChannel(CHANNEL, messagingCallback);
    			}
    		});
    
    		sendBtn.addClickHandler(new ClickHandler() {
    
    			@Override
    			public void onClick(ClickEvent event) {
    				String text = textItem.getValueAsString();
    				SubscriberUtil.sendMessage(CHANNEL, text);
    			}
    		});
    	}
    
    }
    and

    Code:
    package com.smartgwt.sample.client.util;
    
    import com.smartgwt.client.rpc.Messaging;
    import com.smartgwt.client.rpc.MessagingCallback;
    import com.smartgwt.client.rpc.RPCCallback;
    import com.smartgwt.client.rpc.RPCRequest;
    import com.smartgwt.client.rpc.RPCResponse;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.sample.client.IAConstants;
    
    public class SubscriberUtil {
    
    	private static MessagingCallback messagingCallback = new MessagingCallback() {
    
    		@Override
    		public void execute(Object data) {
    			disconnect();
    		}
    	};
    
    	private static void disconnect() {
    		IAConstants.logOut(true);
    	}
    
    	public static void subscribeToChannel(String channel) {
    		Messaging.subscribe(channel, messagingCallback);
    	}
    
    	public static void subscribeToChannel(String channel,
    			MessagingCallback callback) {
    		Messaging.subscribe(channel, callback);
    	}
    
    	public static void unSubscribeFromChannel(String channel) {
    		Messaging.unsubscribe(channel);
    	}
    
    	public static void sendMessage(String channel, String message) {
    		Messaging.send(channel, message, new RPCCallback() {
    
    			@Override
    			public void execute(RPCResponse response, Object rawData,
    					RPCRequest request) {
    				if (response.getStatus() != RPCResponse.STATUS_SUCCESS)
    					SC.say("Failed to send message to server.");
    			}
    		});
    	}
    
    	public static void sendLoginMessage(String channel) {
    		Messaging.send(channel, "newSession", new RPCCallback() {
    
    			@Override
    			public void execute(RPCResponse response, Object rawData,
    					RPCRequest request) {
    				if (response.getStatus() != RPCResponse.STATUS_SUCCESS)
    					SC.say("Failed to send message to server.");
    			}
    		});
    	}
    }
    And in case it helps, here's the key part in my tomcat configuration:

    Code:
       <Connector port="8080" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8443" />
    
            <Connector className="org.apache.catalina.connector.http.HttpConnector"
                    port="8081" scheme="https" secure="true" protocol="HTTP/1.1"
                   connectionTimeout="20000"
               proxyName="192.168.1.181"
               proxyPort="8080"/>
    As well, here's some additional background info:Additional details:
    ======================
    SmartGWT (not smartclient) Version: SmartClient Version: v8.3p_2012-11-26/PowerEdition Deployment (built 2012-11-26)
    ...
    Browser: Chrome on Win 7
    GWT SDK: 2.5.0rc2
    Sun JDK 1.6.0_13
    J2EE: Tomcat 6
    OS: Centos 6.x
    IDE: MyEclipse 10.6 with Google Plugin for Eclipse (3.1.0)

    #2
    Just a quite note (your support is expired and you're asking about known-working features) - you need to look at what's actually happening on the network using Firebug and similar tools.

    Comment


      #3
      We've requested the invoice so that we can renew support. My administrator is awaiting your sale's reps invoice. I'm assuming we'll get it today.

      That said, this is what I discovered.

      It works *perfectly fine* under tomcat when using FireFox (Windows or Mac OS) and Safari (Mac OS); it does NOT work at all on Chrome (either Windows of Mac OS) -- there are no errors, it just doesn't seem to pick up the messages. I tried both with the LocalMessageDispatcher and JMSMessageDispatcher. I then tried playing with some settings (shown below), but it had no visible impact. There is a "FireBug Lite" for chrome (not the full version) -- should I used that to help provide info to you? If so, what info would be most expedient to help resolve this issue? (Does Chrome work for you/others for real time messaging when using Tomcat and "LocalMessageDispatcher)?)

      Here's the settings I tried for the server.properties (please note many elements are commented out):

      Code:
      # ---server.properties----
      messaging.keepaliveInterval: 3000
      messaging.keepaliveReestablishDelay: 1000
      messaging.connectTimeout: 4000
      messaging.connectionTTL: 120000
      messaging.flushBufferSize: 89056
      #messaging.dispatcherImplementer: com.isomorphic.messaging.JMSMessageDispatcher
      #messaging.jms.context: _container_
      #messaging.jms.jndiPrefix: jms messaging.jms.topicConnectionFactory: MyTopicConnectionFactory
      messaging.dispatcherImplementer: com.isomorphic.messaging.LocalMessageDispatcher
      #messaging.dispatcherImplementer: com.isomorphic.messaging.JMSMessageDispatcher
      jndi.messaging.java.naming.factory.initial: org.apache.activemq.jndi.ActiveMQInitialContextFactory
      # jndi.messaging.java.naming.provider.url: tcp://hostname:61616
      jndi.messaging.java.naming.provider.url: vm://localhost
      messaging.jms.context: _container_
      messaging.jms.jndiPrefix:
      messaging.jms.topicConnectionFactory: jms/ConnectionFactory

      Comment


        #4
        Yes, Chrome works fine for us and for others.

        Just hit F12 in Chrome and a tool very similar to Firebug appears.

        Comment


          #5
          I compared Firefox + FireBug (where messages are being sent and received) with Chrome+Chrome Developer tools (where Chrome is SENDING fine; but NOT receiving.). I noticed that:

          1) In Firefox, once I click on a button to "subscribe" to the "testChannel", I can see the initial post request, and I can see subsequent post request every few seconds (presumably to keep the channel open).

          2) In Chrome, though, I do NOT see such a corresponding "post" request when I click on the button that executes the "subscribe" command.

          (Again: In chrome, I *can* send a message, and though I can't retrieve it in Chrome, I am able to retrieve the message in Firefox. So Chrome is sending messages.)

          Any clues or suggestions?

          A few other tidbits that may not be relevant: I'm using https; I'm using localDispatchServlet; the browser is a popup window instead of a regular tab; I'm using both Apache Tomcat as well as an httpd front-end.

          I don't think any of these points are relevant (since messaging is working fine in Safari and Firefox, but I'm just listing out anything that might be unusual.)

          Comment


            #6
            I did notice the followwing (which I initially ignored since I didn't think the "output1.rss.include" website had any relevance):

            Code:
            Uncaught SecurityError: Blocked a frame with origin "https://ia-informatics-platform.com:444" from accessing a frame with origin "https://output1s.rssinclude.com". Protocols, domains, and ports must match. ISC_Core.js:919
            isc_HiddenFrame__draw ISC_Core.js:919
            isc_HiddenFrame_draw ISC_Core.js:916
            isc_HiddenFrame_sendForm ISC_Core.js:926
            isc_c_Comm_sendHiddenFrame ISC_DataBinding.js:2315
            isc_c_Messaging__connectCallback ISC_RealtimeMessaging.js:57
            (anonymous function) messaging?ts=1395768069764:4
            The last part -- ISC_RealtimeMessaging.js -- seems like the issue, here, right? I'm not sure how one url, output1s.rssinclude.com, which is being blocked should cause other routines (such as ISC_RealtimeMessaging.js) to be blocked...Is this normal?

            Comment


              #7
              Yup, there's your problem. Chrome is picky about the port number not matching, whereas other browsers may not be.

              Comment


                #8
                That seemed to be the problem. I got rid of the reference to the tab that contained the "output1.rss.include" code that was causing Chrome's security exception, and then the SmartGWT realt-time messaging worked in Chrome.

                That said, ironically, I never did see the "post" request in Chrome's developer tools for the "subscribe" even the way I saw them in Firefox/FireBug. (I presume the SmartGWT realt-time "subscribe" method works differently in Chrome?)

                On a different note: how long do messages remain active? Is there a way to set some sort of expiry, so that messages not retrieved say within 5 minutes get expired and are no longer retrievalble by a client? Otherwise, I'd assume that we might somehow have too many messages and consume too much Java memory or hard disk space?

                Comment


                  #9
                  Some details are different for Chrome by necessity (we use something called Server-Sent Events in Chrome, because of course, each browser has a different set of bugs..), which means the request is a GET instead of a POST, however, this shows up in Chrome's Developer tools with no special effort.

                  Messages do not have an expiry because they are sent immediately and do not wait around in server memory at all.

                  Comment

                  Working...
                  X