Reputation: 1
I'm certainly missing something obvious but I can't figure it out. I'm trying to get the Lightstreamer sdk to work on a macOS project in swift.
Everything compiles perfectly and runs without errors but the log systematically indicates Status: CONNECTING.
Stranger still, if I indicate a url which is not a Lightstreamer server the behavior is the same, no error in the logs, just "connecting" for ever.
HTTP requests via URLSession work without problems.
class TestSDK{
let delegateTest = SubscriptionDelegateImpl()
let loggerProvider = ConsoleLoggerProvider(level: .debug)
init(){
LightstreamerClient.setLoggerProvider(loggerProvider)
let client = LightstreamerClient(serverAddress: "https://push.lightstreamer.com/", adapterSet: "DEMO")
client.connect()
let items = [ "item1", "item2", "item3" ]
let fields = [ "stock_name", "last_price" ]
let sub = Subscription(subscriptionMode: .MERGE, items: items, fields: fields)
sub.dataAdapter = "QUOTE_ADAPTER"
sub.requestedSnapshot = .yes
sub.addDelegate(delegateTest)
client.subscribe(sub)
}
}
and the logs :
serverAddress changed: https://push.lightstreamer.com/
adapterSet changed: DEMO
Connection requested: details: [serverAddress: https://push.lightstreamer.com/, adapterSet: DEMO, libVersion: swift_client 6.1.1] options: [requestedMaxBandwidth: unlimited, retryDelay: 4000, firstRetryMaxDelay: 100, sessionRecoveryTimeout: 15000, stalledTimeout: 2000, reconnectTimeout: 3000, idleTimeout: 19000, contentLength: 50000000]
Status: CONNECTING
WS connecting: https://push.lightstreamer.com/lightstreamer Sec-WebSocket-Protocol: TLCP-2.5.0.lightstreamer.com
subscriptionDidAddDelegate called
Subscription requested: subId: 1 [mode: MERGE, items: ["item1", "item2", "item3"], fields: ["stock_name", "last_price"], dataAdapter: QUOTE_ADAPTER, requestedSnapshot: yes]
Upvotes: 0
Views: 61
Reputation: 1
Found the solution thanks to you. As I suspected, it was a newbie mistake, coming from a different language I didn't thought the garbage collector was this quick...
class TestSDK{
let delegateTest = SubscriptionDelegateImpl()
let loggerProvider = ConsoleLoggerProvider(level: .debug)
var client:LightstreamerClient // solution here, strong reference
init(){
LightstreamerClient.setLoggerProvider(loggerProvider)
client = LightstreamerClient(serverAddress: "https://push.lightstreamer.com/", adapterSet: "DEMO")
client.connect()
let items = [ "item1", "item2", "item3" ]
let fields = [ "stock_name", "last_price" ]
let sub = Subscription(subscriptionMode: .MERGE, items: items, fields: fields)
sub.dataAdapter = "QUOTE_ADAPTER"
sub.requestedSnapshot = .yes
sub.addDelegate(delegateTest)
client.subscribe(sub)
}
}
Upvotes: 0