jrief / django-websocket-redis

Websockets for Django applications using Redis as message queue
http://django-websocket-redis.awesto.com/
MIT License
896 stars 222 forks source link

Safari websocket problem #206

Open Marcolino179 opened 7 years ago

Marcolino179 commented 7 years ago

On Safari 10.0 and macOS Sierra, i can't connect to ws server, the error reported is "failed: Invalid HTTP version string: HTTP/1.0"

jrief commented 7 years ago

well, WS are an addition the the 1.1 version of the HTTProtocol. How is it, that Safari still want's to talk HTTP/1.0 ? Can this be configured somewhere?

Btw. I really don't understand Apple's policy of keeping Safari such a legacy browser. Looking at caniuse, Safari (together with IE) is the browser which offers the smallest number of modern features.

written with a Chrome 53 browser

Uninen commented 7 years ago

I have this same problem with Safari Version 10.0 (11602.1.50.0.10) on OS X El Capitan. Any ideas how to go around this?

rafe-g commented 7 years ago

@jrief i see this as well however only see this on safari client 10.0.1 (11602.2.14.0.7). Chrome 54.0.2840.98 and Firefox 47.0 work fine. Its definitely browser dependent. Looks like something in safari's latest 10.0.1 rollout broke this client.

jrief commented 7 years ago

Thanks for investigating this. But since it's Apple, you're are probably out of luck. They are so snooty, that they won't even ignore such a report. Therefore, I tell all my clients that the only purpose of Safari is to download Chrome or Firefox.

Uninen commented 7 years ago

This is an interesting approach to the problem. So instead of trying to figure out the problem itself and fixing the software, blaming the user for her preferences (or place of work, for example). Personally I don't want to do this for my end clients (and even if I did insult them it still wouldn't fix the problem with the code).

I'm afraid I seem not to have deep enough knowledge of Websockets to help with the actual code (hence I'm using a library in the first place), but I'm quite confident this is fixable as other libraries don't seem to have the problem.

And as for the library itself, thank you for your work, it has served me very well for a long time before there were big tools like Channels.

jrief commented 7 years ago

@Uninen If somebody using ws4redis has a client, who is willing to pay on that investigation, I'd be glad to help and fix it. But currently I have no urgent need to fix it on Safari, therefore unless someone else want's to work on, please go ahead. Since I pilfered to underlying low-level websocket library myself, chances are high that it has been fixed there already (annotation.: that library is included instead of referenced, because some patches have to be applied).

Nowadays it seems to be the expectation of many users of OSS, that all projects have to be maintained for free forever. This is not how sustainable OSS development can work. I'm the maintainer of some other, quite popular OSS projects, and those I'm currently working on, are funded. Even Andrew Godwin got some kind of funding (I don't know the amount) for his work on Channels.

mheiges commented 7 years ago

I think the problem is that Django's runserver talks HTTP/1.0 (https://code.djangoproject.com/ticket/25619) and newer Safari/WebKit versions are no longer willing to accept the wrong protocol for websockets (https://bugs.webkit.org/show_bug.cgi?id=82714).

drewthaler commented 7 years ago

@mheiges is right, it's caused by Django runserver returning HTTP/1.0 for all of its responses, including the initial WebSocket upgrade response... which is technically invalid because upgrading is a HTTP/1.1 feature. So Safari's not wrong, it's just obnoxious that it's throwing an assertion on it suddenly when it used to work.

The fix (workaround?) that I applied to get it working under Safari 10.0 was to simply set the http_version in the ServerHandler. Took some digging to figure out how exactly to hook it in as it's several levels of indirection away, but here's the change to my local runserver.py that made it work for me.

ws4redis-safari-fix.diff.txt

siddo420 commented 7 years ago

is HTTP basic authentication being used somewhere? Or HAProxy?