mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
improved reconnect to compensate for ARM wake times
This commit is contained in:
parent
5dba6315ac
commit
a894c739c8
3 changed files with 58 additions and 41 deletions
|
|
@ -42,17 +42,21 @@
|
||||||
(handler-case
|
(handler-case
|
||||||
(cond ((and id (gethash id *connection-data*))
|
(cond ((and id (gethash id *connection-data*))
|
||||||
(format t "Reconnection id - ~A to ~A~%" id connection)
|
(format t "Reconnection id - ~A to ~A~%" id connection)
|
||||||
|
(let ((old (gethash id *connection-ids*)))
|
||||||
|
(when *verbose-output*
|
||||||
|
(format t "Transfer id - ~A => ~A" old connection))
|
||||||
|
(setf (gethash old *connections*) nil)
|
||||||
|
(setf (gethash connection *connections*) id)
|
||||||
|
(setf (gethash id *connection-ids*) connection)
|
||||||
(handler-case
|
(handler-case
|
||||||
(websocket-driver:close-connection (gethash id *connection-ids*)
|
(websocket-driver:close-connection old
|
||||||
"Aborting this old connection since receiving a reconnection request.")
|
"Aborting this old connection since receiving a reconnection request.")
|
||||||
(t (c)
|
(t (c)
|
||||||
(when *verbose-output*
|
(when *verbose-output*
|
||||||
(format t "Failed to close the old connection when establishing reconnection. ~
|
(format t "Failed to close the old connection when establishing reconnection. ~
|
||||||
This can be normal: The old connection could not work for the client, ~
|
This can be normal: The old connection could not work for the client, ~
|
||||||
so the client is requesting to reconnect.~%Condition - ~A.~&"
|
so the client is requesting to reconnect.~%Condition - ~A.~&"
|
||||||
c))))
|
c))))))
|
||||||
(setf (gethash id *connection-ids*) connection)
|
|
||||||
(setf (gethash connection *connections*) id))
|
|
||||||
(id
|
(id
|
||||||
(format t "Reconnection id ~A not found. Closing the connection.~%" id)
|
(format t "Reconnection id ~A not found. Closing the connection.~%" id)
|
||||||
(websocket-driver:close-connection connection)) ; Don't send the reason for better security.
|
(websocket-driver:close-connection connection)) ; Don't send the reason for better security.
|
||||||
|
|
@ -162,6 +166,14 @@
|
||||||
|
|
||||||
(defun handle-close-connection (connection)
|
(defun handle-close-connection (connection)
|
||||||
"Close websocket CONNECTION. (Private)"
|
"Close websocket CONNECTION. (Private)"
|
||||||
|
(when *verbose-output*
|
||||||
|
(format t "Connection close request ~A.~%"
|
||||||
|
connection))
|
||||||
|
(when *reconnect-delay*
|
||||||
|
(when *verbose-output*
|
||||||
|
(format t "Connection close request ~A delayed ~A for reconnects.~%"
|
||||||
|
connection *reconnect-delay*))
|
||||||
|
(sleep *reconnect-delay*))
|
||||||
(handler-case
|
(handler-case
|
||||||
(let ((id (gethash connection *connections*)))
|
(let ((id (gethash connection *connections*)))
|
||||||
(when id
|
(when id
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ script."
|
||||||
(*browser-gc-on-ping* variable)
|
(*browser-gc-on-ping* variable)
|
||||||
(*break-on-error* variable)
|
(*break-on-error* variable)
|
||||||
(*disable-clog-debugging* variable)
|
(*disable-clog-debugging* variable)
|
||||||
|
(*reconnect-delay* variable)
|
||||||
|
|
||||||
(initialize function)
|
(initialize function)
|
||||||
(random-port function)
|
(random-port function)
|
||||||
|
|
@ -87,6 +88,7 @@ script."
|
||||||
(defvar *browser-gc-on-ping* nil "Run a browser-gc on every ping (default nil)")
|
(defvar *browser-gc-on-ping* nil "Run a browser-gc on every ping (default nil)")
|
||||||
(defvar *break-on-error* t "Allow invoking debugger (default t)")
|
(defvar *break-on-error* t "Allow invoking debugger (default t)")
|
||||||
(defvar *disable-clog-debugging* nil "When true turns off debug hooks (default nil)")
|
(defvar *disable-clog-debugging* nil "When true turns off debug hooks (default nil)")
|
||||||
|
(defvar *reconnect-delay* 3 "Time to delay in seconds for possible reconnect (default 3)")
|
||||||
|
|
||||||
(defvar *on-connect-handler* nil "New connection event handler.")
|
(defvar *on-connect-handler* nil "New connection event handler.")
|
||||||
|
|
||||||
|
|
|
||||||
11
tools/preferences.lisp.sample
vendored
11
tools/preferences.lisp.sample
vendored
|
|
@ -84,14 +84,17 @@
|
||||||
(setf *editor-delay-on-eval-file* 60)
|
(setf *editor-delay-on-eval-file* 60)
|
||||||
|
|
||||||
;; Server Settings
|
;; Server Settings
|
||||||
;; When true turns off debug hooks
|
;; when true turns off debug hooks
|
||||||
(setf clog-connection:*disable-clog-debugging* nil)
|
(setf clog-connection:*disable-clog-debugging* nil)
|
||||||
;; Verbose server output
|
;; verbose server output
|
||||||
(setf clog-connection:*verbose-output* nil)
|
(setf clog-connection:*verbose-output* nil)
|
||||||
;; Run a browser-gc on every ping
|
;; run a browser-gc on every ping
|
||||||
(setf clog-connection:*browser-gc-on-ping* nil)
|
(setf clog-connection:*browser-gc-on-ping* nil)
|
||||||
;; Allow invoking debugger
|
;; allow invoking debugger
|
||||||
(setf clog-connection:*break-on-error* t)
|
(setf clog-connection:*break-on-error* t)
|
||||||
|
;; time to delay for possible reconnect, such as after sleep or
|
||||||
|
;; long network latenacies.
|
||||||
|
(setf clog-connection:*reconnect-delay* 3)
|
||||||
|
|
||||||
;; CLOG Builder REPL
|
;; CLOG Builder REPL
|
||||||
(setf *clog-repl-use-console* t)
|
(setf *clog-repl-use-console* t)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue