I do have the mod_proxy_wstunnel module loaded.
I realised that I am getting an error in apache:

No protocol handler was valid for the URL /chat/stream/. If you are using a 
DSO version of mod_proxy, make sure the proxy submodules are included in 
the configuration using LoadModule.

I've tried a lot of the suggestions i've sound through google but nothing 
seems to work. Perhaps this Mac OS X Server.app Apache install has issues. 

Thanks anyway Andrew!



On Thursday, 22 December 2016 13:15:36 UTC-3, Andrew Godwin wrote:
>
> Apache's default mod_proxy does not support WebSockets. If you want to 
> keep using Apache I would consider looking at mod_proxy_wstunnel.
>
> Andrew
>
> On Thu, Dec 22, 2016 at 2:24 PM, Adam Teale <[email protected] 
> <javascript:>> wrote:
>
>> Hi everyone,
>>
>> I have a django app running on mac os x server via mod_wsgi (apache 2.4).
>>
>> I am using proxypass to point to daphne (running on port 8000).
>>
>> As far as I can tell things should be running ok. Daphne is being run via 
>> this command:
>>
>> daphne mysite.asgi:channel_layer -v2 -p 8000
>>
>> When ever I access the url with the Channels chat demo app (/chat) daphne 
>> prints the following:
>>
>> 2016-12-22 10:58:15,398 INFO     Starting server at 127.0.0.1:8000, 
>> channel layer mysite.asgi:channel_layer
>>
>> 2016-12-22 10:58:15,400 INFO     Using busy-loop synchronous mode on 
>> channel layer
>>
>> 2016-12-22 10:58:18,342 DEBUG    HTTP GET request for 
>> http.response!SAKtXWGjqdCG
>>
>> 2016-12-22 10:58:18,373 DEBUG    HTTP 200 response started for 
>> http.response!SAKtXWGjqdCG
>>
>> 2016-12-22 10:58:18,373 DEBUG    HTTP close for http.response!SAKtXWGjqdCG
>>
>> 2016-12-22 10:58:18,374 DEBUG    HTTP response complete for 
>> http.response!SAKtXWGjqdCG
>>
>> 127.0.0.1:49944 - - [22/Dec/2016:10:58:18] "GET /chat/" 200 6550
>>
>> 2016-12-22 10:58:18,440 DEBUG    HTTP GET request for 
>> http.response!mDjckxncNYGS
>>
>> 2016-12-22 10:58:18,476 DEBUG    HTTP 200 response started for 
>> http.response!mDjckxncNYGS
>>
>> 2016-12-22 10:58:18,477 DEBUG    HTTP close for http.response!mDjckxncNYGS
>>
>> 2016-12-22 10:58:18,477 DEBUG    HTTP response complete for 
>> http.response!mDjckxncNYGS
>>
>> 127.0.0.1:49950 - - [22/Dec/2016:10:58:18] "GET /chat/stream/" 200 6550
>>
>> 2016-12-22 10:58:19,527 DEBUG    HTTP GET request for 
>> http.response!lCwBwWsyjxGf
>>
>> 2016-12-22 10:58:19,550 DEBUG    HTTP 200 response started for 
>> http.response!lCwBwWsyjxGf
>>
>> 2016-12-22 10:58:19,551 DEBUG    HTTP close for http.response!lCwBwWsyjxGf
>>
>> 2016-12-22 10:58:19,551 DEBUG    HTTP response complete for 
>> http.response!lCwBwWsyjxGf
>>
>> ...
>>
>>
>>
>>
>> The rqworker also:
>>
>>
>> mysite.local
>>
>> 2016-12-22 10:58:31,984 - DEBUG - worker - Got message on http.request 
>> (reply http.response!MLkDhtLSmyEy)
>>
>> 2016-12-22 10:58:31,985 - DEBUG - runworker - http.request
>>
>> 2016-12-22 10:58:31,985 - DEBUG - worker - Dispatching message on 
>> http.request to channels.staticfiles.StaticFilesConsumer
>>
>>
>> The error I am getting in safari & chrome is:
>> "WebSocket connection to 'wss://mysite.local/chat/stream/' failed: 
>> WebSocket is closed before the connection is established. response code: 
>> 200"
>>
>>
>> When I access the site on from the server via localhost:8000/chat 
>> everything works fine and daphne prints out:
>>
>> 2016-12-22 11:03:10,393 DEBUG    HTTP GET request for 
>> http.response!MJBzHhZMRNnb
>>
>> 2016-12-22 11:03:10,406 DEBUG    HTTP 200 response started for 
>> http.response!MJBzHhZMRNnb
>>
>> 2016-12-22 11:03:10,407 DEBUG    HTTP close for http.response!MJBzHhZMRNnb
>>
>> 2016-12-22 11:03:10,407 DEBUG    HTTP response complete for 
>> http.response!MJBzHhZMRNnb
>>
>> 127.0.0.1:50013 - - [22/Dec/2016:11:03:10] "GET /chat" 200 6550
>>
>> 2016-12-22 11:03:10,411 DEBUG    WebSocket closed for 
>> websocket.send!wlxnNRjdYtZi
>>
>> 127.0.0.1:50026 - - [22/Dec/2016:11:03:10] "WSDISCONNECT /chat/stream/" 
>> - -
>>
>> 2016-12-22 11:03:10,413 DEBUG    HTTP GET request for 
>> http.response!aGsxTkWhWXxh
>>
>> 2016-12-22 11:03:10,415 DEBUG    HTTP GET request for 
>> http.response!fOyocApjCNFZ
>>
>> 2016-12-22 11:03:10,416 DEBUG    HTTP GET request for 
>> http.response!EdzYIGSakoQB
>>
>> 2016-12-22 11:03:10,429 DEBUG    HTTP 304 response started for 
>> http.response!fOyocApjCNFZ
>>
>> 2016-12-22 11:03:10,430 DEBUG    HTTP close for http.response!fOyocApjCNFZ
>>
>> 2016-12-22 11:03:10,430 DEBUG    HTTP response complete for 
>> http.response!fOyocApjCNFZ
>>
>> 127.0.0.1:50034 - - [22/Dec/2016:11:03:10] "GET 
>> /static/css/style_chat.css" 304 -
>>
>> 2016-12-22 11:03:10,431 DEBUG    HTTP 304 response started for 
>> http.response!EdzYIGSakoQB
>>
>> 2016-12-22 11:03:10,432 DEBUG    HTTP close for http.response!EdzYIGSakoQB
>>
>> 2016-12-22 11:03:10,432 DEBUG    HTTP response complete for 
>> http.response!EdzYIGSakoQB
>>
>> 127.0.0.1:50035 - - [22/Dec/2016:11:03:10] "GET 
>> /static/js/reconnecting-websocket.min.js" 304 -
>>
>> 2016-12-22 11:03:10,433 DEBUG    HTTP 304 response started for 
>> http.response!aGsxTkWhWXxh
>>
>> 2016-12-22 11:03:10,433 DEBUG    HTTP close for http.response!aGsxTkWhWXxh
>>
>> 2016-12-22 11:03:10,433 DEBUG    HTTP response complete for 
>> http.response!aGsxTkWhWXxh
>>
>> 127.0.0.1:50013 - - [22/Dec/2016:11:03:10] "GET 
>> /static/js/jquery-1.12.2.min.js" 304 -
>>
>> 2016-12-22 11:03:10,446 DEBUG    WebSocket open for 
>> websocket.send!GTaoMdCohNRJ
>>
>> 127.0.0.1:50038 - - [22/Dec/2016:11:03:10] "WSCONNECT /chat/stream/" - -
>>
>> 2016-12-22 11:03:10,447 DEBUG    Upgraded connection 
>> http.response!uqNYcIilOUmR to WebSocket websocket.send!GTaoMdCohNRJ
>>
>>
>> And the rqworker
>>
>> 2016-12-22 11:03:43,757 - DEBUG - worker - Got message on http.request 
>> (reply http.response!lSnLnqtZGeAQ)
>>
>> 2016-12-22 11:03:43,758 - DEBUG - runworker - http.request
>>
>> 2016-12-22 11:03:43,758 - DEBUG - worker - Dispatching message on 
>> http.request to channels.staticfiles.StaticFilesConsumer
>>
>> mysite.local
>>
>> 2016-12-22 11:03:43,775 - DEBUG - worker - Got message on 
>> websocket.disconnect (reply websocket.send!GTaoMdCohNRJ)
>>
>> 2016-12-22 11:03:43,775 - DEBUG - runworker - websocket.disconnect
>>
>> 2016-12-22 11:03:43,775 - DEBUG - worker - Dispatching message on 
>> websocket.disconnect to chat.consumers.ws_disconnect
>>
>> 2016-12-22 11:03:43,782 - DEBUG - worker - Got message on http.request 
>> (reply http.response!jsOmihXNuAaw)
>>
>> 2016-12-22 11:03:43,782 - DEBUG - runworker - http.request
>>
>> 2016-12-22 11:03:43,782 - DEBUG - worker - Dispatching message on 
>> http.request to channels.staticfiles.StaticFilesConsumer
>>
>> 2016-12-22 11:03:43,784 - DEBUG - worker - Got message on http.request 
>> (reply http.response!LhlHYluUriEy)
>>
>> 2016-12-22 11:03:43,784 - DEBUG - runworker - http.request
>>
>> 2016-12-22 11:03:43,785 - DEBUG - worker - Dispatching message on 
>> http.request to channels.staticfiles.StaticFilesConsumer
>>
>> 2016-12-22 11:03:43,786 - DEBUG - worker - Got message on http.request 
>> (reply http.response!ZheYuJkmIcDU)
>>
>> 2016-12-22 11:03:43,786 - DEBUG - runworker - http.request
>>
>> 2016-12-22 11:03:43,786 - DEBUG - worker - Dispatching message on 
>> http.request to channels.staticfiles.StaticFilesConsumer
>>
>> 2016-12-22 11:03:43,814 - DEBUG - worker - Got message on 
>> websocket.connect (reply websocket.send!EbTqxrVaYgyb)
>>
>> 2016-12-22 11:03:43,815 - DEBUG - runworker - websocket.connect
>>
>> 2016-12-22 11:03:43,815 - DEBUG - worker - Dispatching message on 
>> websocket.connect to chat.consumers.ws_connect
>>
>>
>> My current attempt with apache's proxy_module / proxy_wstunnel_module is 
>> the following in a .conf file:
>>
>> ProxyRequests Off
>> ProxyPreserveHost On
>>
>> RewriteEngine on
>> RewriteCond %{REQUEST_URI} ^/chat/stream [NC,OR]
>> RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
>> RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
>> RewriteRule .* wss://localhost:8000%{REQUEST_URI} [P,QSA,L]
>>         
>> <Location /chat/stream>
>>     Require all granted
>>     ProxyPass ws://localhost:8000/chat/stream
>>     ProxyPassReverse wss://localhost:8000/chat/stream
>> </Location>
>>
>> <Location /chat>
>>     Require all granted
>>     ProxyPass http://localhost:8000/chat
>>     ProxyPassReverse http://localhost:8000/chat
>> </Location>
>>
>>
>> Can anyone shed some light on what this could be about? Is this an apache 
>> config issue?
>>
>>
>> Thanks!
>>
>> Adam
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/a24905c5-2ee0-4e19-9b13-7cab3e16c6f6%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/a24905c5-2ee0-4e19-9b13-7cab3e16c6f6%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9cff3a60-36e8-4f50-862f-0f0e699b2218%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to