Fixing error where connection was re-established incorrectly
This commit is contained in:
parent
896bafe70b
commit
12bd5e6a01
@ -113,7 +113,15 @@ func (d *Dispatcher) dispatchMessage(msg *message.Message) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Println("Websocket terminated: reconnecting")
|
log.Println("Websocket terminated: reconnecting")
|
||||||
|
err := d.Disconnect()
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
d.Connect()
|
d.Connect()
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
subsList := d.store.GetAll()
|
subsList := d.store.GetAll()
|
||||||
for i := range subsList {
|
for i := range subsList {
|
||||||
sub := subsList[i]
|
sub := subsList[i]
|
||||||
|
@ -46,6 +46,10 @@ func (w *Websocket) Init(endpoint string, options *transport.Options) error {
|
|||||||
|
|
||||||
w.stopCh = make(chan error)
|
w.stopCh = make(chan error)
|
||||||
w.conn, _, err = websocket.DefaultDialer.Dial(endpoint, options.Headers)
|
w.conn, _, err = websocket.DefaultDialer.Dial(endpoint, options.Headers)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = w.conn.UnderlyingConn().(*tls.Conn).NetConn().(*net.TCPConn).SetKeepAlive(true)
|
err = w.conn.UnderlyingConn().(*tls.Conn).NetConn().(*net.TCPConn).SetKeepAlive(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user