-
Notifications
You must be signed in to change notification settings - Fork 327
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
Are Python WebSockets under SSL intended to work? #1019
Comments
Thanks for your honest feedback! We are ware of the current debugging capabilities and we are working on it making it better! Let's use this issue to identify challenges and what we can do to help you. First of all, can you please share what OS and Unit Version you are using locally AND on your production server? Did you installed the Python Module using our Packages? On Dev and Prod? Have you tried using certs and websockets on your local dev machine? Is this working? Are there any errors in the unit log? Have you tried to run Unit in debug-mode on Prod to get a more detailed log output? The Unit debug binaries comes with your package (based on the OS you are using on Prod). |
Thanks for the quick reply. Dev is macOS, prod is Ubuntu 23.04. Using the official packages for Python support. Haven't tried using certs locally, will try that now to see how that goes. Didn't see anything of note in the unit log, but also am not running in debug-mode in prod, so can try that if I don't find anything from running SSL certs locally. |
Quick question. Are you using wss:// in production? does ws:// work there? |
We are indeed using wss:// in production, and ws:// locally. Have not tried to use ws:// in production, currently trying to get wss:// working locally first. |
EDIT: Ignore the below, misconfiguration on my end. I was able to get WebSockets working just fine locally with the wss:// scheme with a local SSL cert. One thing I realized when doing this process, however, is that locally I am always specifying a port ( old comment
|
After messing around with the production environment and looking at the logs, I am actually seeing two errors repeatedly that definitely seem related:
and
|
If you hit the thing with You could try explicitly specifying :443 in the url, but that would seem a little bonkers if that actually worked... |
I might be a bit dense, but what do you want me to hit with verbose curl? Tried specifying 443 explicitly, indeed did not seem to help. |
Yes, ignore me. Many years ago I wrote a websocket server and misremembered using curl to check the handshake stuff, it was most probably tcpdump/wireshark...
This is likely going to need a reproducer app. Don't suppose you have a minimal example or a pointer to one? |
Yep, I will see if I can make a very simple repro in the next few days. Somewhat difficult because the websockets are working in dev, so it also might be an Ubuntu issue. |
Hi, I recently changed over our infrastructure to use Nginx Unit, and mostly it is going great. The only thing that is not going great is that this seems to have broken WebSockets for our app in production.
Our app is a Python ASGI app (FastAPI) so from what I've read it seems like WebSockets should be supported just fine, and while developing locally using Unit they do indeed work great. However in production they seem to be broken. As far as I can figure, the only difference between dev and prod is that prod is (of course) using an SSL cert, while dev on localhost is of course not. The stack before was Gunicorn w/ Uvicorn + Nginx + HAProxy, which had to have a number of tweaks and fiddles at the different layers to get WS working correctly, but working they were.
Is this a known issue? Are there any remediations I can try? A great thing about Unit is that it has massively reduced the config required to serve our application. The bad thing is that when something is broken it is hard to try to debug different layers of the stack because there is only the one 😅. I've tried debugging at the application level itself and that seems to be a deadend, so for now I've concluded the issue must be with how Unit is working alongside the application/WebSockets.
For reference, here are my Unit configs in dev and prod.
dev config
prod config
Thanks for any help and thank you for making a great piece of software like Unit!
The text was updated successfully, but these errors were encountered: