Commit 30437dce authored by ibuler's avatar ibuler

[Update] 修改支持重连

parent a5c621f4
package httpd package httpd
import ( import (
"context"
"net" "net"
"net/http" "net/http"
"path/filepath" "path/filepath"
...@@ -16,7 +17,7 @@ import ( ...@@ -16,7 +17,7 @@ import (
var ( var (
httpServer *http.Server httpServer *http.Server
Timeout = time.Duration(60) Timeout = time.Duration(10)
) )
var upgrader = gorilla.Upgrader(gorillaws.Upgrader{ var upgrader = gorilla.Upgrader(gorillaws.Upgrader{
...@@ -69,6 +70,10 @@ func StartHTTPServer() { ...@@ -69,6 +70,10 @@ func StartHTTPServer() {
} }
sshWs.OnConnect = func(c *neffos.Conn) error { sshWs.OnConnect = func(c *neffos.Conn) error {
if c.WasReconnected() { if c.WasReconnected() {
namespace := c.Socket().Request().Header.Get("X-Namespace")
if namespace != "" {
_, _ = c.Connect(context.TODO(), "ssh")
}
logger.Debugf("Connection %s reconnected, with tries: %d", c.ID(), c.ReconnectTries) logger.Debugf("Connection %s reconnected, with tries: %d", c.ID(), c.ReconnectTries)
} else { } else {
logger.Debug("A new ws connection arrive") logger.Debug("A new ws connection arrive")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment