pmusolino / Wormholy

iOS network debugging, like a wizard 🧙‍♂️
MIT License
2.32k stars 184 forks source link

Wormholy and other dependencies working with URLSessions #77

Open Alex601t opened 4 years ago

Alex601t commented 4 years ago

When both Wormholy and Alamofire 5 are installed as dependencies in project, Wormholy affects on correct Alamofire working, in particular:

When application uploading data via Alamofire 5:

AF.upload(multipartFormData: { multipartFormData in
multipartFormData.append(data, withName: "data")
}, to: urlString)
.uploadProgress { progress in
    print(progress)
}
 .response { resp in
    print(respect)
} 

uploadProgress closure is not being called. After deinstalling Wormholy from the project Alamofire 5 is working correctly.

pmusolino commented 4 years ago

Hi there. What version of Xcode and Swift are you using?

Alex601t commented 4 years ago

Hi there. What version of Xcode and Swift are you using?

Xcode Version 11.2.1, Swift 5.0

pmusolino commented 4 years ago

Thanks Alex. @kealdishx this can be a good example of a call that doesn't work like expected.

kealdishx commented 4 years ago

OK, I will take a look at the issue and make a reponse if anything updated.

kealdishx commented 4 years ago

It seems that there is no way for your URLProtocol subclass to call URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend: method, so upload progress will never be called. @pmusolino

pmusolino commented 4 years ago

Interesting @kealdishx. Do you have the demo project where you tried it? I'll try to work on it unless you've already started working on it.

kealdishx commented 4 years ago

That's just a guess.I found something from apple-ios-example:

Similarly, there is no way for your NSURLProtocol subclass to call the NSURLConnection delegate's -connection:needNewBodyStream: or -connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite: methods (rdar://problem/9226155 and rdar://problem/9226157). The latter is not a serious concern--it just means that your clients don't get upload progress--but the former is a real issue. If you're in a situation where you might need a second copy of a request body, you will need your own logic to make that copy, including the case where the body is a stream.

I don't have free time recently, so I haven't proved it yet. Do you have interest in going on with it?Or I'll solve the issue when I'm free. @pmusolino

pmusolino commented 4 years ago

Related issue https://github.com/pmusolino/Wormholy/issues/76

pmusolino commented 4 years ago

Related issue https://github.com/pmusolino/Wormholy/issues/56

pmusolino commented 4 years ago

@kealdishx same as you. I'll try to fix it asap, but if you found some free time and you have the possibility to take a look at it, I will be grateful to you! 🙇‍♂️

gblock92 commented 3 years ago

I have a similar issue going on in my project. I installed this pod azure-notificationhubs-ios and it has a method that makes a network request. When having Wormholy Installed the network request always times out. When removing Wormholy, the request gets called just fine and doesn't timeout.

pmusolino commented 3 years ago

Hey @gblock92 can you retry using the latest version released some hours ago please? https://github.com/pmusolino/Wormholy/releases/tag/1.6.3

gblock92 commented 3 years ago

@pmusolino I updated the pod to the latest version (1.6.3) and it looks like the issue is still there. The request still times out when Wormholy is added.

ZsoltMolnarrr commented 3 years ago

Hello! Our development team is unable to use wormholy due to this issue. @pmusolino Can we have an update on this please? We would greatly appreciate the resolution of this problem. 🙏

cernym46 commented 3 years ago

Hi, I'm facing a similar issue. I can't make the delegate get called until the whole request is ignored by Wormholy (works fine when I uncomment the line in viewDidLoad).

import UIKit
import Wormholy

class ViewController: UIViewController {

    lazy var session: URLSession = URLSession(configuration: .default, delegate: self, delegateQueue: nil)

    override func viewDidLoad() {
        super.viewDidLoad()
//        Wormholy.ignoredHosts = ["httpbin.org"]

        var request = URLRequest(url: URL(string: "https://httpbin.org/post")!)
        request.httpMethod = "POST"
        let data = Data(count: 10_000)
        let task: URLSessionUploadTask = session.uploadTask(
            with: request,
            from: data
        ) { data, response, error in
            print("task done")
        }
        task.resume()
    }
}

extension ViewController: URLSessionTaskDelegate {
    func urlSession(
        _ session: URLSession,
        task: URLSessionTask,
        didSendBodyData bytesSent: Int64,
        totalBytesSent: Int64,
        totalBytesExpectedToSend: Int64
    ) {
        print("bytesSent: \(bytesSent)")
    }
}
thethtun commented 3 years ago

I was trying to get upload progress. Neither Alamofire or NSURLSesssion works. It took me awhile to figure this out. I have seen many similar cases on stackoverflow. Unbeknown to a lot of people (including me), most thought it's the issue with alamofire.

dyegos commented 3 years ago

Hi. I am having the same issue in my project, we are using a new API and that specific host is not working when using Wormholy. All other APIs' hosts we have implemented works fine. Only this one is problematic when using Wormholy.

I am using Wormholy 1.6.4 and Xcode 12.5.

pmusolino commented 2 years ago

I released a new (big) version of Wormholy (1.6.5) with some improvements and fixes. https://github.com/pmusolino/Wormholy/releases/tag/1.6.5 Can you test it and let me know if you are still encountering this issue?

cernym46 commented 2 years ago

Unfortunately the problem persists

gauravborole commented 2 years ago

Checked with latest version Wormholy (1.6.5), problem still persists. uploadProgress closure is not getting called. It works after removing Wormholy from the project.