Changeset 487
- Timestamp:
- 08/12/08 09:34:09 (5 months ago)
- Location:
- trunk/daemon
- Files:
-
- 6 modified
-
orbited-debug.cfg (modified) (2 diffs)
-
orbited.cfg (modified) (1 diff)
-
orbited/cometsession.py (modified) (4 diffs)
-
orbited/config.py (modified) (1 diff)
-
orbited/proxy.py (modified) (2 diffs)
-
orbited/static/Orbited.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/daemon/orbited-debug.cfg
r486 r487 2 2 reactor=epoll 3 3 proxy.enabled=1 4 session.ping_interval = 5 5 session.ping_timeout = 5 4 6 5 7 [listen] … … 19 21 * -> localhost:6163 20 22 * -> localhost:7 21 localhost:8001-> localhost:666723 * -> localhost:6667 22 24 23 25 [logging] -
trunk/daemon/orbited.cfg
r486 r487 3 3 #reactor=epoll 4 4 proxy.enabled=1 5 session.ping_interval = 40 6 session.ping_timeout = 30 5 7 6 8 [listen] -
trunk/daemon/orbited/cometsession.py
r486 r487 140 140 hostHeader = property(lambda s: s.transportProtocol.hostHeader) 141 141 142 def _get_pingTimeout(self): 143 return self.transportProtocol._pingTimeout 144 145 def _get_pingInterval(self): 146 return self.transportProtocol._pingInterval 147 148 def _set_pingTimeout(self, v): 149 self.transportProtocol.pingTimeout = v 150 self.transportProtocol.send(TCPOption('pingTimeout', v)) 151 152 def _set_pingInterval(self, v): 153 self.transportProtocol.pingInterval = v 154 self.transportProtocol.send(TCPOption('pingInterval', v)) 155 156 # Determines timeout interval after ping has been sent 157 pingTimeout = property(_get_pingTimeout, _set_pingTimeout) 158 # Determines interval to wait before sending a ping 159 pingInterval = property(_get_pingInterval, _set_pingInterval) 160 161 142 162 class TCPConnectionResource(resource.Resource): 143 163 pingTimeout = 30 164 pingInterval = 30 144 165 logger = logging.get_logger('orbited.cometsession.TCPConnectionResource') 145 146 # Determines timeout interval after ping has been sent147 pingTimeout = 40148 # Determines interval to wait before sending a ping149 # since the last time we heard from the client.150 pingInterval = 40151 166 152 167 def __init__(self, root, key, peer, host, hostHeader, **options): … … 381 396 elif isinstance(data, TCPClose): 382 397 self.cometTransport.sendPacket('close', str(packetId)) 398 elif isinstance(data, TCPOption): 399 self.cometTransport.sendPacket('opt', str(packetId), data.payload) 383 400 else: 384 401 self.cometTransport.sendPacket('data', str(packetId), base64.b64encode(data)) … … 392 409 # self.cometTransport.sendPacket('id', ackId) 393 410 411 412 413 414 415 394 416 class TCPPing(object): 395 417 pass … … 398 420 pass 399 421 422 class TCPOption(object): 423 def __init__(self, name, val): 424 self.payload = str(name) + ',' + str(val) 425 400 426 class TCPResource(resource.Resource): 401 427 -
trunk/daemon/orbited/config.py
r486 r487 10 10 #'proxy.enabled': '1', 11 11 12 'pid.location': '/tmp/orbited.pid' 12 'pid.location': '/tmp/orbited.pid', 13 'session.ping_interval': '30', 14 'session.ping_timeout': '30' 13 15 }, 14 16 -
trunk/daemon/orbited/proxy.py
r486 r487 12 12 'Unauthorized': 106, 13 13 } 14 pingTimeout = int(config.map['[global]']['session.ping_timeout']) 15 pingInterval = int(config.map['[global]']['session.ping_interval']) 16 14 17 15 18 class ProxyIncomingProtocol(Protocol): … … 23 26 def connectionMade(self): 24 27 # TODO: add handshake timer 28 self.transport.pingTimeout = pingTimeout 29 self.transport.pingInterval = pingInterval 25 30 self.logger.debug("connectionMade") 26 31 self.state = 'handshake' -
trunk/daemon/orbited/static/Orbited.js
r485 r487 350 350 var handshakeTimer = null; 351 351 var cometTransport = null; 352 var pingInterval = 30000; 353 var pingTimeout = 30000; 354 var timeoutTimer = null; 352 355 var lastPacketId = 0 353 356 var sending = false; … … 376 379 sessionKey = xhr.responseText; 377 380 ;;; self.logger.debug('session key is: ', sessionKey) 381 resetTimeout(); 378 382 sessionUrl = new Orbited.URL(_url) 379 383 // START new URL way … … 524 528 break; 525 529 } 526 } 530 break; 531 case 'opt': 532 var args = frame.data.split(',') 533 switch(args[0]) { 534 case 'pingTimeout': 535 pingTimeout = parseInt(args[1])*1000 536 break 537 case 'pingInterval': 538 pingInterval = parseInt(args[1])*1000 539 break; 540 default: 541 ;;; self.logger.warn('unknown opt key', args[0]) 542 break; 543 } 544 } 545 resetTimeout(); 527 546 } 528 547 var transportOnClose = function() { … … 606 625 var doClose = function(code) { 607 626 ;;; self.logger.debug('doClose', code) 627 unsetTimeout(); 608 628 self.readyState = self.READY_STATE_CLOSED; 609 629 cometTransport.onReadFrame = function() {} … … 615 635 self.onclose(code); 616 636 637 } 638 639 var resetTimeout = function() { 640 unsetTimeout(); 641 timeoutTimer = window.setTimeout(timedOut, pingInterval + pingTimeout); 642 } 643 var unsetTimeout = function() { 644 window.clearTimeout(timeoutTimer); 645 646 } 647 var timedOut = function() { 648 doClose(Orbited.Errors.ConnectionTimeout) 617 649 } 618 650 }; … … 1089 1121 break; 1090 1122 case 4: 1123 var doReconnect = true; 1091 1124 try { 1092 xhr.status 1125 if (xhr.status === null) { 1126 doReconnect = true; 1127 } 1128 else { 1129 doReconnect = false; 1130 } 1093 1131 } 1094 1132 catch(e) { 1133 } 1134 if (doReconnect) { 1095 1135 // Expoential backoff: Every time we fail to 1096 1136 // reconnect, double the interval. … … 1099 1139 // self.logger.debug('retryInterval', retryInterval) 1100 1140 window.clearTimeout(heartbeatTimer); 1101 window.setTimeout(reconnect, retryInterval)1141 retryTimer = window.setTimeout(reconnect, retryInterval) 1102 1142 return; 1103 1143 } 1104 1105 1144 switch(xhr.status) { 1106 1145 case 200: