Hi,
I'm trying to see why the following doesn't work. I see the "Socket
opened" and after a small wait the "Socket closed" messages but never
the "Socket messaged". Initially I had something more complicated,
but in an effort to debug, I switched everything to "alert()", and
added the heartbeat in the JavaScript code, and debug statements
and .ws_stream.receive_message call in the Python code. (The HTML is
at
http://research.gallaudet.edu/~kjcole/pywebsocket/progress.php but
I'm not seeing how that will impact the problem.) The relevant bits
(I think) are:
______________________________________________________________________
JavaScript:
| var socket = null;
|
| function connect() {
| socket = new WebSocket("ws://
research.gallaudet.edu/progress");
| socket.onopen = function () { alert("Socket opened"); };
| socket.onerror = function () { alert("Socket error"); };
| socket.onclose = function (event) { alert("Socket closed"); };
| socket.onmessage = function (event) { alert("Socket messaged"); };
| setInterval(function() { socket.send("Heartbeat"); }, 60000);
| }
|
| window.onload = function() {
| connect();
| }
______________________________________________________________________
Python:
| import time
|
| def web_socket_do_extra_handshake(request):
| pass
|
| def web_socket_transfer_data(request):
| line = request.ws_stream.receive_message() # Must receive a
message?
| debug = open("/tmp/websock.log","a")
| debug.write("Received data transfer request:\n")
| debug.write(line)
| debug.close()
| progress = 0 # Initialize
counter
| while True: # Ad nauseum...
| progress = (progress + 1) % 101 # ...count from 0
to 100
| request.ws_stream.send_message(progress) # ...send progress
back
| time.sleep(0.5) # ...sleep for 0.5
seconds
______________________________________________________________________
Background:
I'm using Ubuntu LTS, mod_pywebsocket-0.6b1, python2.6
(2.6.5-1ubuntu6), apache2 (2.2.14-5ubuntu8.4), and libapache2-mod-
python (3.3.1-8ubuntu2).
The console.html demo with both echo_wsh and bench_wsh are working
both in standalone and under Apache -- albeit with a very short
tolerance for inactivity -- I haven't adjusted apache's configuration:
| RequestReadTimeout header=10-20,minrate=500
| RequestReadTimeout body=10,minrate=500
| KeepAlive On
| MaxKeepAliveRequests 100
| KeepAliveTimeout 15