Posts

Post not yet marked as solved
4 Replies
5.9k Views
My iOS app obtains streamed events from an endpoint. I use the following code successfully to initiate streaming and worked beautifully before iOS 13. Now the following code will generate an error: func startStreaming() { precondition( !self.isStreaming ) // // create a request and task to start streaming // if let request = SensorInventory.setupHTTPRequestForURL(SensorProject.projectBaseUrlString + "/devices:stream") { let task = self.session.uploadTask(withStreamedRequest: request) self.streamingTask = task task.resume() } } The method setupHTTPRequestForURL simply creates a request object with a base 64 encoded string of key and password and sets the value for the httpHeaderField: request.httpMethod = "GET" request.setValue("Basic \(base64LoginString)", forHTTPHeaderField: "Authorization") No error is thrown in iOS 12 - streamed data is returned however in iOS 13: 2019-09-22 18:00:27.728325-0700 DTSensors[9880:1176642] GET method must not have a body 2019-09-22 18:00:27.728938-0700 DTSensors[9880:1173067] Task <4D2AF35D-EA2F-4CEA-BFEE-5AF936AC3BAF>.<1600> finished with error [-1103] Error Domain=NSURLErrorDomain Code=-1103 "resource exceeds maximum size" UserInfo={NSLocalizedDescription=resource exceeds maximum size, NSErrorFailingURLStringKey=https://api.disruptive-technologies.com/v2/projects/bhm5ru43iktucae701rg/devices:stream, NSErrorFailingURLKey=https://api.disruptive-technologies.com/v2/projects/bhm5ru43iktucae701rg/devices:stream, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalUploadTask <4D2AF35D-EA2F-4CEA-BFEE-5AF936AC3BAF>.<1600>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <4D2AF35D-EA2F-4CEA-BFEE-5AF936AC3BAF>.<1600>, NSUnderlyingError=0x600001509950 {Error Domain=kCFErrorDomainCFNetwork Code=-1103 "(null)"}}When I examine the request structure I see (sensitive data is removed at ***):https://api.YYYY.com/v2/projects/XXXXXXXXX/devices:stream ▿ url : Optional<URL> ▿ some : https://api.YYYY.com/v2/projects/XXXXXXXXX/devices:stream - _url : https://api.YYYY.com/v2/projects/XXXXXXXXX/devices:stream - cachePolicy : 0 - timeoutInterval : 60.0 - mainDocumentURL : nil - networkServiceType : __C.NSURLRequestNetworkServiceType - allowsCellularAccess : true ▿ httpMethod : Optional<String> - some : "GET" ▿ allHTTPHeaderFields : Optional<Dictionary<String, String>> ▿ some : 1 element ▿ 0 : 2 elements - key : "Authorization" - value : "Basic Ymhxb2hlajI0dGUwMDBiMjR2ajA6NjQ0YWQ2MTgxN2E0NDA3MWI4OTEyM2EwNzI2ZGE2MTY=" - httpBody : nil - httpBodyStream : nil - httpShouldHandleCookies : true - httpShouldUsePipelining : false- Note that the httpBody is nil in contrast to what the output above describesAnyone have a suggestion about how to address this problem? NB The same basic authorization works just fine if I am asking the endpoint for data, it just does not work if I attempt to initiate streaming.Thanks!
Posted
by QBit47.
Last updated
.
Post not yet marked as solved
5 Replies
2.6k Views
My app responds to incoming server side event stream when in the foreground but not while in the background. Can someone point me to a resource or some examples of how to set up the URLSession and URLRequest? Remember, I've got this working when the app is in the foreground.
Posted
by QBit47.
Last updated
.