Daphne: websocket works locally with ws protocol, but it connects and quickly disconnects in production

Yes, the reason why I thought of that is because I compared it with what I have locally, and that is the only thing that is different.

We use cloudflare, and maybe that might also be an issue.

One example:
Locally, if I run the client on localhost:3000 and the server on 127.0.0.1:8000, the websocket does not work, but it works when I run the client on 127.0.0.1:3000.

Is this currently with or without the AllowedHostsOriginValidator and JWTAuthMiddleware?

It is with both of them.

Ok, what I think you really need to do at this point is take a step back and start from a more fundamental basis - a simpler test case, so that you can identify what it is in your stack that is causing the issue.

I think you should take the Channels chat tutorial and deploy that into your production environment. Build on that step-by-step until you find where things stop working.

There are just too many variables involved with what you have now to do effective debugging.

Thanks @KenWhitesell,

Will do!

Hi @KenWhitesell ,

Thanks for your help. I finally resolved the issue. It was the NGINX configuration. I had proxy_hide_header Upgrade; in the config file. I removed it, and everything works well now.

Thank you so much for your time.