[rabbitmq-discuss] RabbitMQ subscriber loses connection across firewalls after long idle

Deelo55 dwayne.dsouza at gmail.com
Mon Jul 2 10:34:00 BST 2012


Hi,
My test class starts the subscriber...waits 5 minutes than publishes a
message. When I run it locally it works fine...when I run across firewall it
fails.
The hearbeat doesn't help here and when I check on the server it still has
the connection up and running.


public class TimeoutTest {
	private static final Logger log =
LoggerFactory.getLogger(TimeoutTest.class);
	public static void main(String[] args) throws Exception{
		final RabbitMqPublisher<String> publisher=new
RabbitMqPublisher<String>("xxx.xxx.xxx.xxx","EXCHANGE","TEST");
		final RabbitMqSubscriber<String> subscriber=new
RabbitMqSubscriber<String>("xxx.xxx.xxx.xxx","EXCHANGE", "TEST");
		subscriber.setListener(new MessageListener<String>() {
			
			@Override
			public void receive(String s) {
				System.out.println("SUCCESSFUL!!!"); //NEVER GETS CALLED!!!
				
			}
		});
		Executors.newSingleThreadExecutor().execute(new Runnable() {
			public void run() {
				try{
				subscriber.run();
				}catch(Exception e){
					e.printStackTrace();
				}
			}
		});
		
		//start subscriber then wait >5 minutes before publishing first message 
		int timeout=1000*401;
		System.out.println("timeout="+timeout);
		Thread.sleep(timeout);
		
		publisher.publish("MESSAGE PUBLISHED");
		
	}
	
}

--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/RabbitMQ-subscriber-loses-connection-across-firewalls-after-long-idle-tp20480p20487.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list