Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wormholy and other dependencies working with URLSessions #77

Open
Alex601t opened this issue Mar 21, 2020 · 20 comments
Open

Wormholy and other dependencies working with URLSessions #77

Alex601t opened this issue Mar 21, 2020 · 20 comments
Labels
help wanted Extra attention is needed

Comments

@Alex601t
Copy link

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 pmusolino added the help wanted Extra attention is needed label Mar 31, 2020
@pmusolino
Copy link
Owner

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

@Alex601t
Copy link
Author

Alex601t commented Apr 1, 2020

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

Xcode Version 11.2.1, Swift 5.0

@pmusolino
Copy link
Owner

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

@kealdishx
Copy link
Contributor

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

@kealdishx
Copy link
Contributor

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
Copy link
Owner

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
Copy link
Contributor

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
Copy link
Owner

Related issue #76

@pmusolino
Copy link
Owner

Related issue #56

@pmusolino
Copy link
Owner

@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
Copy link

gblock92 commented Sep 4, 2020

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
Copy link
Owner

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
Copy link

gblock92 commented Sep 8, 2020

@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
Copy link

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
Copy link

cernym46 commented Mar 14, 2021

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
Copy link

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
Copy link

dyegos commented May 25, 2021

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
Copy link
Owner

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
Copy link

Unfortunately the problem persists

@gauravborole
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

9 participants