Can hunchensocket and hunchentoot share the same port?
muyinliu opened this issue · comments
Like hunchensocket and hunchentoot use the same port 8080
?
@joaotavora
hunchensocket and hunchentoot can use the same port but due to websocket-acceptor
extends from acceptor
, default websocket-acceptor
can only handle websocket connection and static files relative to the path passing :document-root
while make-instance
of websocket-acceptor
.
After modified the code to make websocket-acceptor
extends from easy-acceptor
rather than acceptor
, you can use hunchentoot:define-easy-handler
and other function to define flexible handler and will not cause conflict with websocket handler. That's great, isn't it?
Or extends both websocket-acceptor
and easy-acceptor
like this:
(defclass super-acceptor (hunchensocket:websocket-acceptor
hunchentoot:easy-acceptor)
())
then use super-acceptor
:
(hunchentoot:start (make-instance 'super-acceptor :port 8080))
Perfect!!
I have an existing hunchentoot app and now a hunchensockets, I'd like to merge the two to use the same acceptor and port. I'm not too familiar with hunchen{toot,socket} internals. Is this bad for websocket performance if the existing http app has several handlers on its hunchentoot:*dispatch-table*
?
I don't think there are performance problems while hunchentoot and hunchensockets share the same port.