I need to create multiple simultaneous sockets and starscream consistently hangs if I try to create over 64 of them.
So this code fails, the connected callback never gets triggered.
# Class var
var websockets = [WebSocket]()
# In a method
for index in 1...64 {
if let newWebSocket = WebSocket(url: YOUR_WS_URL) as WebSocket? {
newWebSocket.onConnect = {
print("\(index) Connected")
}
newWebSocket.onDisconnect = { (error) -> Void in
print("\(index) Discconnected")
}
print("\(index) Connecting")
newWebSocket.connect()
self.websockets.append(newWebSocket)
}
}
Seems to be related to this issue http://stackoverflow.com/questions/15150308/workaround-on-the-threads-limit-in-grand-central-dispatch and the way starscream always dispatches on the background https://github.com/daltoniam/Starscream/blob/master/WebSocket.swift#L144
Maybe move this into a static private operation queue?
I need to create multiple simultaneous sockets and starscream consistently hangs if I try to create over 64 of them.
So this code fails, the connected callback never gets triggered.
Seems to be related to this issue http://stackoverflow.com/questions/15150308/workaround-on-the-threads-limit-in-grand-central-dispatch and the way starscream always dispatches on the background https://github.com/daltoniam/Starscream/blob/master/WebSocket.swift#L144
Maybe move this into a static private operation queue?