-
-
Notifications
You must be signed in to change notification settings - Fork 788
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
503 in the middle of long requests #746
Comments
503 just means your server didn't return a response in time - the Daphne HTTP timeout is 60 seconds by default, I think, as nearly all sites should respond faster than that. You can increase it with command line options if you really want. |
Oh, is there any documentation on here for this? The default django timeout is 300s https://docs.djangoproject.com/en/1.11/ref/settings/ and so Daphne isn't using this? How do I set the one for Daphne? |
There's no specific documentation but |
So Django has its own http_timeout arg. Will setting this also set it for Daphne? If not, how would I set it for Daphne as I'm using the EDIT: Nevermind, I see this here
So for anyone who comes across this, just run
|
Oh, you mean the runserver argument. We should honour that but we don't right now, you'll have to run daphne separately if you want to set it. |
See above comment, the help method of |
Oh maybe it does. I forget. |
Do I need to do additional steps for channels 2? Each websocket connection ran through channels 2 is terminated with a 503 error after ~60 seconds. I use |
A 503 error code is not something emitted by Channels - what are you running it behind? Are you sure it can pass WebSocket connections correctly? Have you tried connecting to Daphne directly and seeing what happens? |
I start channels using the Django development server using
Chrome 63.0.3239.132 then reports The websocket at the server:
I'm using Python 3.5.3 with:
No errors when starting
|
Same behavior from edge btw. And Chrome 64.0.3282.140. No difference when I start Also does not work when I start it using daphne: Using a different protocol in the URL scheme ( |
I'm facing the same issue on Firefox
|
Can I get people who have failing code to paste me what the consumer they're trying to connect to looks like? |
I have the same problem with this simple echo consumer: class Websocket(WebsocketConsumer):
def receive(self, text_data, **kwargs):
self.send(text_data=text_data)
application = ProtocolTypeRouter({
"websocket": URLRouter([
url("", Websocket)
])
}) and this in a browser: socket = new WebSocket("ws://localhost:8000");
setInterval(function() {
socket.send('test');
}, 5000) Started with "runserver -v 2", the output is:
Somehow the "http_protocol" seems to thinks its still responsible for the connection and closes it after a timeout, i think here: https://github.com/django/daphne/blob/3b2fb6f78e7bbee887663cb64e81e735b09134ee/daphne/http_protocol.py#L236-L242 The
Maybe because what is stated in this comment line here looks like its never actually done? I see no code to remove the "reply channel association" after this comment |
Aha, yes, that's it. I didn't twig that this was a websocket working perfectly for 60 seconds and then getting a 503 sent to it. Fixing it. |
I tried various ways and I have the http time out issue as well. The simplest example is to use the Websocket consumer directly in
|
This should be fixed by django/daphne@105e1d5. I'll do a daphne release momentarily. |
Tested and confirmed. No time out errors (503) with your latest commit. |
Released in |
I'm still getting this on channels 2.0.2 and Daphne 2.1.0. My websocket connections are being closed after HTTP timeout seconds with invalid frame header. |
@ianjw11 I encountered the same issue and it was solved by setting --http-timeout in daphne. |
Is there a backwards-compatible fix for 1.X here? I am seeing the same error there. (NB: obviously we'd love to upgrade, but we utterly failed at accounting for performance when trying it previously) |
Afraid not, the 1.x and 2.x codebases are different enough that it'd be too much work for the small team we have to fix. Plus, Daphne 1.x has way more code paths that can make 503 errors because of the fact it doesn't run applications internally, so it might not even be the same root cause. Sorry. |
Did you ever find a work around w/ 1.x? |
No. I need to check on the state of the middleware bug that’s preventing us
from upgrading
…On Fri, Oct 12, 2018 at 7:17 PM Christopher Stanchak < ***@***.***> wrote:
Is there a backwards-compatible fix for 1.X here? I am seeing the same
error there. (NB: obviously we'd love to upgrade, but we utterly failed at
accounting for performance when trying it previously)
Did you ever find a work around w/ 1.x?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#746 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEPpeaONzzlppEfwLQjMofluqbFX5W_ks5ukSMegaJpZM4Pel-q>
.
|
using |
face the similar problem |
@wynshiter please stop cross-posting your issue on other threads. |
If you're submitting a bug report, please include:
OS: Mac OS Sierra
Browser: Google Chrome
Channels: 1.1.6
daphne: 1.3.0
Twisted: 17.5.0
Django: 1.11.5
ASGI Backend: asgi_redis
Running channels from just runserver, heres my redis config:
so on long requests, django returns a 503 to the frontend in the middle of the request. If I set a breakpoint somewhere, then leave the breakpoint running, then a 503 is returned. I'm fairly sure that this is caused by channels somehow as this has never happened before. Anybody have any insight here?
The text was updated successfully, but these errors were encountered: