2

I am unable to create a websocket with vhots enabled through apache2 on my local machine. In FF:

WebSocket is not defined
var socket = new WebSocket('ws://test.localhost.in/soc') 

Chrome gives a 404 Error.

Routes file has been defined properly.

WS      /soc                                    Home.HomeWebSocket.listen

VHost config:

<VirtualHost *>
    ProxyPreserveHost on
    ServerName localhost.in
    ServerAlias *.localhost.in
    ProxyPass / http://localhost:9000/
    ProxyPassReverse / http://localhost:9000/
    SetEnv force-proxy-request-1.0 1
    SetEnv proxy-nokeepalive 1
</VirtualHost>

I can confirm it is due to VHosts because I can successfully run the chat example through localhost:9000/ but not test.localhost.in.

Sameer Segal
  • 21,813
  • 7
  • 42
  • 56

1 Answers1

1

Apache's proxy module apparently does not know about WebSockets. You could try to use mod_pywebsocket.

Also have a look at this question.

Community
  • 1
  • 1
Carsten
  • 17,991
  • 4
  • 48
  • 53
  • With Play! which is better: running apache or Nginx? – Sameer Segal Feb 20 '12 at 13:37
  • That question is too general to answer it simply. I personally am running Play behind nginx, but that's just a matter of taste -- I don't really have any high performance requirements. I suggest that you write down what you need from your front-end HTTP server (e.g. load balancing, virtual hosts, WebSocket support) and check which webserver supports it. Then test/benchmark the ones you like. The manual has a section on [webserver configuration](http://www.playframework.org/documentation/1.2.4/production) and [deployment options](http://www.playframework.org/documentation/1.2.4/deployment). – Carsten Feb 20 '12 at 14:27
  • Thanks. I was looking through the docs and read that nearly 9.7% of the net was served from nginx servers in Feb 2012. Many large russian websites like Yandex etc use it – Sameer Segal Feb 20 '12 at 15:01
  • 1
    for a 'static' usage as a frontend nginx is definitely a better option that apache2 - really suited the task, lighter and faster, great caching system, etc. Alternatives exist, such as [lighttpd](http://www.lighttpd.net/). For hosting a dynamic website (wsgi, php, etc.) the answer is of course more complex... Beware that nginx conf can be a hell for newbies! my 2 cents – Stefano Feb 20 '12 at 15:16
  • @Carsten could you please take a look at this question: http://stackoverflow.com/questions/9372722/vhots-nginx-config-for-playframework-websockets – Sameer Segal Feb 21 '12 at 05:38