kasketis / netfox

A lightweight, one line setup, iOS / OSX network debugging library! 🦊
MIT License
3.68k stars 374 forks source link

Request timeout when uploading file using Multi-part Post request #116

Closed rajanbalana closed 6 years ago

kasketis commented 6 years ago

Hi, Please provide more details about the issue (what version do you use, request executed natively or via 3rd party library, steps to reproduce, etc)

rajanbalana commented 6 years ago

Environment:

OS: iOS 11 Networking Library: AFNetworking (2.6.3)

Steps to reproduce:

Step 1: Make a request to the HTTPS Server, request type should be Multi-part POST

Step 2: Observe till the request timeout. You will see the following error:

Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x600000c43e40 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=URL_HERE, NSErrorFailingURLKey=URL_HERE, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}

Let me know, if you need any more details

kasketis commented 6 years ago

Thanks for the info. Are you sure the timeout is related with the netfox e.g if you disable netfox the request is executed successfully?

rajanbalana commented 6 years ago

Absolutely. I tried the same, as soon as I disable the library. Request goes through.

kasketis commented 6 years ago

Is it easy to execute the same request using Apple's standard API + netfox?

rajanbalana commented 6 years ago

Yes. It must be very straight-forward. However, I haven't tried the same.

kasketis commented 6 years ago

I meant if it is easy you to try it :)

Janglinator commented 6 years ago

@kasketis I uploaded a quick test application below. I'm not quite sure what's going wrong, would you be able to check it out?

TEST.zip

Here is the toilet these posts are going to, so you can see what was sent.

As you can see the normal posts work, and multipart works if you comment out NFX.start() in the view controller, but the multipart requests aren't going through with Netfox enabled.

Don't judge my code :P

P.S. no, there's no viruses in the zip. Here's proof

Janglinator commented 6 years ago

Also, I noticed when we do a regular post, the "Request" column doesn't show my [foo:bar] dictionary, but it does on the multipart post. I wonder what's up with that?

kasketis commented 6 years ago

Thanks @Janglinator! I reproduced the timeout issue but I want to dive into it more. Regarding the body issue you mentioned above, I think it is related with this (check the radar and the #16 ) You can view it on multipart possibly because it sent as httpBodyStream and not as httpBody

jjjjjeffrey commented 6 years ago

I have same issue when using Alamofire to upload file with a stream, 1.10.5 does not have this issue.

Janglinator commented 6 years ago

Netfox 1.10.5 doesn’t have this issue? Interesting!

jjjjjeffrey commented 6 years ago

@Janglinator file uploading can success when I use 1.10.5, but it will be timeout with last version.

ghost commented 6 years ago

Hey, Did you get the time to look into the issue? I tried to look into the code but was unable to understand the underlying issue.

alextud commented 6 years ago

I think that issue is related to this pull. https://github.com/kasketis/netfox/pull/102. There is an inputstream that is open / read simultaneous by 2 actors. And this may cause some callbacks/delegates to not be triggered.

ghost commented 6 years ago

Any update?

alextud commented 6 years ago

hey we've made a pull request for this issue see https://github.com/kasketis/netfox/pull/120

ghost commented 6 years ago

@alextud That works! I have integrated your fork into my project. Thanks a ton!

felipeflorencio commented 6 years ago

As far I see was fixed by @alextud , and his update already was merged đź‘Ť , so, if anyone still get any issue regarding this let us know

RolandasRazma commented 5 years ago

not sure how is this fixed. We see same behaviour in v1.15.0 (any above 1.10.5) when posting multipart forms. Adding NFXProtocol.self to URLSessionConfiguration doesn't help either

NoIf728 commented 5 years ago

same as @RolandasRazma

ankitgarg1mg commented 4 years ago

Still getting same issue in 1.9.0. @felipeflorencio can you please look into this

ismailkilic commented 4 years ago

Still getting same issue in 1.9.0. @felipeflorencio can you please look into this

I agree with you, I still have this issue.