Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    Dec 2008
    Location
    Bangalore
    Posts
    20

    Thumbs up LSClient Not giving any error if the LS Server is not running

    Hi,

    I turned my LS server down, and tried to run my app, with possible registration to all the events i could expect. Well, nothings happening, the client waits for some min's and silently dies down. How can I get the info that my server is not running? The status change is getting invoked, and it is displaying

    DISCONNECTED => CONNECTING

    After this, nothing happening. The code is below. Please help me out.


    Code:
    private function connectToLs(connector:LSConnector):void{
    			lsClient = new LSClient();
    			
    			lsClient.addEventListener(StatusChangeEvent.STATUS_CHANGE,onLSStatusChange);
    			lsClient.addEventListener(SubscriptionEvent.SUBSCRIPTION,onLSSubscription);
    			lsClient.addEventListener(ServerErrorEvent.SERVER_ERROR,onLSConnectionError);
    			lsClient.addEventListener(ControlErrorEvent.CONTROL_ERROR,onLSConnectionError);
    			lsClient.addEventListener(ControlConnectionErrorEvent.CONTROL_CONNECTION_ERROR,onLSConnectionError);
    				
    				
    			var connectionInfo:ConnectionInfo = new ConnectionInfo();
    			connectionInfo.setServer(connector.host);
    			connectionInfo.setAdapter(connector.mainAdapter);
    			connectionInfo.setControlPort(connector.port);
    			connectionInfo.setPort(connector.port);
    			connectionInfo.setControlProtocol(connector.protocol);
    			connectionInfo.setProtocol(connector.protocol);
    			
    			
    			var connectionPolicy:ConnectionPolicy = new ConnectionPolicy();
    //Tried default nthing happ, so added these lines (These are the default values)
    			connectionPolicy.setTimeoutForStalled(2000);
    			connectionPolicy.setTimeoutForReconnect(15000);
    			connectionPolicy.setRetryTimeout(5000);
    			
    			//Connect to Lightstreamer Server
    			try {
    				lsClient.openConnection(connectionInfo,connectionPolicy);
    			} catch(e:Error) {
    				Alert.show(e.message);//No alert also!!
    			}
    		}
    
    public function onLSStatusChange(event:StatusChangeEvent):void{
    			trace(event.previousStatus + " => " + event.status);
    }

  2. #2
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    That's the correct behavior of the client.
    If the client is not connected to the server it continuously makes new attempts. During those attempts the client status remains CONNECTING.
    You can pose your own limit to connection attempts setting a timeout and "closing the connection" through the closeConnection call once such timeout is reached.

    You can control some of the connection-related behaviors of the client through the ConnectionPolicy object ( http://www.lightstreamer.com/docs/cl...ionPolicy.html )

    HTH.

  3. #3
    Member
    Join Date
    Dec 2008
    Location
    Bangalore
    Posts
    20
    Hi Mone,

    You can see in my code, I am setting setTimeoutForStalled, setTimeoutForReconnect, setRetryTimeout for the connection policy. I have set respectively, 2, 15 and 5 seconds. But even after waiting for 3-4 min, I am not getting to know in any of my callback listeners when is the server actually down. The Flex App is just stuck in waiting mode.

    Also the doc says only for setRetryTimeout the argument in millisec, so i assumed that for the remaining methods args may or may not be in millisec and tried with both type of arguments(sec and millisec). But, still no use.

    Can you please tell me the configuration so that as soon as server is down I get an alert stating that server down?

    Thanks,
    Shreyas

  4. #4
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Such timeouts are used internally to decide when to perform new attempts, but as said in my previous message it is correct that the client remains in the CONNECTING status.

    If you start the server you'll notice that accordingly to the set timeouts the client will reconnect correctly to the server.

    What I meant is that you could set your own timeout to fire a callback after a while and then check if the client is connected or is still CONNECTING. You can set a timeout using the Timer class or the setTimeout method of flex.

    If you'd like to know when attempts are performed you can enable the client logging ( see http://www.lightstreamer.com/docs/cl...ge-detail.html ) and then check the logs.

  5. #5
    Member
    Join Date
    Dec 2008
    Location
    Bangalore
    Posts
    20
    Oh, ok.. I understand what you mean.
    But, just consider this as a feature request.. It will be nice if I can get a handle when LSClient tries to reconnect or when suddenly server goes down. I would like to display the status on the UI saying disconnected, connecting in these many seconds..

    Thanks a lot for making me understand this subject.

  6. #6
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    We'll take your request into consideration for a future release.

    Note that if the server goes down while you're already connected you'll notice a status change through the status callback.

  7. #7
    Member
    Join Date
    Dec 2008
    Location
    Bangalore
    Posts
    20
    Yup, I did observe that. Will use that to display disconnected status :-)

 

 

Similar Threads

  1. Replies: 3
    Last Post: July 29th, 2011, 08:56 AM
  2. Replies: 1
    Last Post: October 21st, 2009, 10:19 AM
  3. Replies: 1
    Last Post: September 18th, 2009, 09:13 AM
  4. Replies: 1
    Last Post: November 5th, 2007, 01:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 06:42 PM.