|
samples
Explain how to install sample codes and how to use these.
IntroductionExplain how to install sample codes and how to use these. These samples works well in chrome4+ only.
How to installGetting sample codes via svn checkout svn checkout http://websocket-sample.googlecode.com/svn/trunk/ websocket-sample-read-only step 1.
step 2.
step 3.
sample codes.
Url::http://somewhere/pub/litechat.html
What's this?::This is lite chat sample. Click 'connect' makes connection to websocket server and 'send' button become available. Type message in the box and click 'send', message will be available to other members. Simply, open at least 2 windows will realize bidirectional connection with websocket protocol.
Url::http://somewhere/pub/counter.html What's this?::This is simple counter sample. It shows number of users connecting this service, ( that's all, what a simple!!) . This sample simply shows how ease to manage connections. Since websocket is state-full protocol, we can manage connection without id ( required cookies for state-less protocol, HTTP ).
Url::http://somewhere/pub/mecab/ruby.html http://somewhere/pub/mecab/wakachi.html
Under http (request & response model), it is hard to send request message while waiting for response messages. Http also has http pipeline technique, but it is difficult to use via browser (for example, firefox requires conifguration via about:config with alert message:p). As a result, it requires long waiting time for users. Test data shows that to request & response about 100 messages, over 30 seconds were measured between japan and U.S.A.
WebSocket makes easy way to utilize websocket pipelining. As shown below, websockets are able to send message repeatedly. Protocol does not require waiting for response, then test data showed that websocket pipeling was extremely faster than http ... about 1 sec!! between japan and U.S.A. You can confirm detailed testing data via my blog site's comment ( http://blog.livedoor.jp/kotesaki/archives/1376548.html : japanese... ). This demonstratoin includes two text mining. One is appending "ruby" (not language :)) to "Kanji" and another is inserting spacer between each words (either are japanese only). This demo needs MeCab, famous japanese text mining open-source product, so on the server side, installing MeCab and python bind are required. This demonstration shows how fast the websocket pipelining is. Comparing "via websocket" vs "via xhr" you'll realize websocket pipelining at least x10 faster than parallel XMLHttpRequest. (I don't know how to type HTTP pipelining in Ajax.Request orz) |
► Sign in to add a comment
Install Tips:
In my websock_handlers directory, I had to set the .py files as executable, and I had to set the shared file e.g count or messages, as writable.
I got errors when viewing count.html with Chrome 5.0.375.126:
Aug 15 20:42:13 2010? error? Handshake error: Header Upgrade is not defined Aug 15 20:42:13 2010? error? Handshake error: Sec-WebSocket?-Key1 not found Aug 15 20:42:13 2010? error? 127.0.0.1? File does not exist: /var/www/pub/count
So I added support for "old handshake" in http.conf as per the readme. Here is my httpd.conf:
ServerName? localhost
<IfModule? python_module>
</IfModule>PythonOption? mod_pywebsocket.allow_draft75 On
Now apache2/error.log reports: Aug 15 20:52:59 2010? error? Handshake error: Sec-WebSocket?-Key1 not found Aug 15 20:52:59 2010? warn? fallback to old protocol
But it works, sorta. Count displays different numbers if I open up duplicate tabs. Chat only lets me send stuff for a few seconds before it locks up, but it does send messages between duplicate tabs.
Could possibly separately draw the attention to:
RequestReadTimeout? body=0
option. I know that the pydoc documentation is included, but the example is the first try, who are not native speakers. Also important security dilemma.