2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-05-01 04:47:45 +00:00

Provide mechanism for client session loss to trigger a teardown

This commit is contained in:
Jarrod Johnson
2026-04-29 15:20:39 -04:00
parent ee8a8bdac7
commit 75776b77a3
3 changed files with 12 additions and 1 deletions

View File

@@ -537,6 +537,8 @@ class ConsoleHandler(object):
for rcpt in list(self.livesessions):
try:
await rcpt.data_handler(data)
except exc.Disconnect:
await rcpt.destroy()
except Exception as e: # No matter the reason, advance to next recipient
print(repr(e))
_tracelog.log(traceback.format_exc(), ltype=log.DataTypes.event,

View File

@@ -146,3 +146,7 @@ class LoggedOut(ConfluentException):
def get_error_body(self):
return '{"loggedout": 1}'
class Disconnect(ConfluentException):
apierrorcode = 503
_apierrorstr = 'Client disconnected'

View File

@@ -17,6 +17,8 @@
# This SCGI server provides a http wrap to confluent api
# It additionally manages httprequest console sessions
import base64
import aiohttp
try:
import Cookie
except ModuleNotFoundError:
@@ -449,7 +451,10 @@ def websockify_data(data):
def datacallback_bound(clientsessid, rsp):
async def datacallback(data):
data = websockify_data(data)
await rsp.send_str(u'${0}$'.format(clientsessid) + data)
try:
await rsp.send_str(u'${0}$'.format(clientsessid) + data)
except aiohttp.client_exceptions.ClientConnectionResetError:
raise exc.Disconnect("Client disconnected")
return datacallback
async def wsock_handler(req):