Solved. My port was wrong. I should have been using 443
Hi,
Has the Flex API been depreciated or is it still supported? I notice there's not been much activity on this part of the forum recently.
I am using Lightstreamer with the new IGIndex API. I am as sure as I can be that I'm using the right login and endpoint but I can't get this to work. I have posted a message on the IGIndex forums to make sure I've got everything right - https://labs.ig.com/node/56.
Interestingly, if I use getDemoConnectionInfo() instead of getConnectionInfo(), i.e. the connection info in your examples, it works as expected. Is there possibly a problem with a secure https connection?
My class follows. All I see in my console is:
onStatusChange CONNECTING
onStatusChange DISCONNECTED
onStatusChange CONNECTING
etc...
Code:
package controllers
{
import com.lightstreamer.as_client.*;
import com.lightstreamer.as_client.events.*;
import flash.utils.*;
import models.*;
/**
* ...
* @author Tim
*/
public class StreamerClient extends LSClient
{
private static var alreadyConstructed:Boolean = false
public function StreamerClient(endpoint:String, clientId:String)
{
super()
if (alreadyConstructed)
{
throw new Error("Only one instance of Lightstreamer allowed. Access it through models.Streamer")
}
alreadyConstructed = true
addClientListeners()
var connectionInfo:ConnectionInfo = getConnectionInfo(endpoint, clientId)
openConnection(connectionInfo)
}
private function addClientListeners():void
{
addEventListener(StatusChangeEvent.STATUS_CHANGE, onStatusChange);
addEventListener(ServerErrorEvent.SERVER_ERROR, onServerError);
addEventListener(ConnectionDropEvent.CONNECTION_DROP, onConnectionDrop);
addEventListener(ControlConnectionErrorEvent.CONTROL_CONNECTION_ERROR, onControlConnectionError);
}
private function getDemoConnectionInfo(endpoint:String, clientId:String):ConnectionInfo
{
var connectionInfo:ConnectionInfo = new ConnectionInfo()
connectionInfo.server = "push.lightstreamer.com"
connectionInfo.controlProtocol = "http"
connectionInfo.protocol = "http"
connectionInfo.port = 80
connectionInfo.controlPort = 80
connectionInfo.adapterSet = "DEMO"
return connectionInfo
}
private function getConnectionInfo(endpoint:String, clientId:String):ConnectionInfo
{
var connectionInfo:ConnectionInfo = new ConnectionInfo()
connectionInfo.password = "CST-" + CST + "|XST-" + X_SECURITY_TOKEN
connectionInfo.user = clientId
connectionInfo.server = endpoint.substr(8) //Strips https:// from the front of the string
connectionInfo.controlProtocol = "https"
connectionInfo.protocol = "https"
connectionInfo.port = 80
connectionInfo.controlPort = 80
connectionInfo.adapterSet = "DEFAULT"
return connectionInfo
}
private function onStatusChange(event:StatusChangeEvent):void
{
trace("onStatusChange", event.status)
}
private function onServerError(event:ServerErrorEvent):void
{
trace("onServerError")
}
private function onConnectionDrop(event:ConnectionDropEvent):void
{
trace("onConnectionDrop")
}
private function onControlConnectionError(event:ControlConnectionErrorEvent):void
{
trace("onControlConnectionError")
}
}
}
Bookmarks