[Django] Requests from iOS time out when raven is enabled
I am having an issue with requests from iOS timing out when Raven is enabled. Any endpoints from my project will time out, but not endpoints that are included from third party apps. The issue disappears when excluding Raven from installed apps. This issue only occurs when sending a request from an iOS app. The same requests made using httpie or Postman are successful.
To make things more complicated, the request only times out on the iOS side. As soon as it times out, Django (or rather runserver) happily reports that the request was successful with a 200 status code.
I apologize for the lack of detailed information or a stack trace, but I have not been able to produce an actual error from the Django application. Please let me know if further information is needed or if you have ideas on things I should investigate further.
URL Structure
As mentioned above, requests for URLs from third-party apps succeed, but any requests to URLs from my project fail.
Base URL File
# project/project/urls.py
urlpatterns = [
url(r'^foo/', include('foo.urls'), # Third party application works fine
url(r'^my-app/', include('my_app.urls'), # Application defined in my project fails
]
App URL File
# project/my_app/urls.py
app_name = 'my-app'
urlpatterns = [
url(r'^bar/$', BarView.as_view(), name='bar-detail'),
]
Views
The views from the project are mostly based on DRF's generic views (eg generics.ListCreateView). I don't believe the issue lies here, since some of the third-party apps used utilize the same generic views.
Dependency Versions
- Django 2.0.3
- Django Rest Framework 3.7.7
- Raven 6.6.0
Downgrading to 6.1.0 causes the requests to work, but constantly logs errors about URLConf, which I believe is related to the Django 2 support that was 6.2.0 addresses.
Upstream Issue
For reference, the upstream issue I'm trying to fix is knowmetools/km-api#298
@cdriehuys Hi Chathan. mind installing a version that doesn't instrument drf to pinpoint the problem?
I'm working on setting up a test project without DRF, but we might not be able to test against it until after the weekend.
On the topic of DRF though, we utilize some third-party apps built on top of DRF that work just fine. Any ideas on why only endpoints from our project would be failing?
Hi @ashwoods. We tested against a test project without DRF, but came across the same behavior. The API doesn't respond until after the connection has timed out or ended, and then responds as expected as soon as that happens.
[26/Mar/2018 15:22:50] "GET /my-app/foo/ HTTP/1.1" 200 18
No additional information comes back regarding the request.
To clarify further, commenting out raven.contrib.django.raven_compat from INSTALLED_APPS causes the request to succeed immediately.
The test project, for reference.
The hanging behavior in Raven 6.2.0 and higher occurs when an empty set of parameters are provided for the http body.
func request(parameters: [String:Any] = [:]) {
...
request.httpBody = try? JSONSerialization.data(withJSONObject: parameters)
...
}
A little extra clarification thank to @cdriehuys . This is happening when the body is set for an endpoint that isn't expecting it. This occurs if the body is empty or not. In our case, it just happened to be empty because of the default value for parameters.
Thx. I’m not entirely sure why, but I can fix it. On Wed 28. Mar 2018 at 19:20, Brandogs [email protected] wrote:
A little extra clarification thank to @cdriehuys https://github.com/cdriehuys . This is happening when the body is set for an endpoint that isn't expecting it. This occurs if the body is empty or not. In our case, it just happened to be empty because of the default value for parameters.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/getsentry/raven-python/issues/1215#issuecomment-376966621, or mute the thread https://github.com/notifications/unsubscribe-auth/AAW4tWyQ_AjcWXbXviuUPucd5oNPjUXqks5ti8ZigaJpZM4S5TcM .