Skip to content

Commit

Permalink
修复:ws connector问题
Browse files Browse the repository at this point in the history
  • Loading branch information
davyxu committed Mar 30, 2019
1 parent a779757 commit 472fc9f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
27 changes: 17 additions & 10 deletions peer/gorillaws/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,24 @@ func (self *wsConnector) connect(address string) {
if self.tryConnTimes == reportConnectFailedLimitTimes {
log.Errorf("(%s) continue reconnecting, but mute log", self.Name())
}
}

// 没重连就退出
if self.ReconnectDuration() == 0 || self.IsStopping() {
// 没重连就退出
if self.ReconnectDuration() == 0 || self.IsStopping() {

self.ProcEvent(&cellnet.RecvMsgEvent{Ses: self.defaultSes, Msg: &cellnet.SessionConnectError{}})
break
}
self.ProcEvent(&cellnet.RecvMsgEvent{
Ses: self.defaultSes,
Msg: &cellnet.SessionConnectError{},
})
break
}

// 有重连就等待
time.Sleep(self.ReconnectDuration())
// 有重连就等待
time.Sleep(self.ReconnectDuration())

// 继续连接
continue

// 继续连接
continue
}
}

self.sesEndSignal.Add(1)
Expand All @@ -142,6 +146,9 @@ func (self *wsConnector) connect(address string) {
time.Sleep(self.ReconnectDuration())
}

self.SetRunning(false)
self.EndStopping()

}

func (self *wsConnector) TypeName() string {
Expand Down
2 changes: 1 addition & 1 deletion tests/db_test.go → tests/db/db_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests
package db

import (
"github.com/davyxu/cellnet"
Expand Down
4 changes: 2 additions & 2 deletions tests/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ func TestRelay(t *testing.T) {
relay_Signal = NewSignalTester(t)
relay_Signal.SetTimeout(time.Second * 5)

relay_backend()

relay_agent()

relay_backend()

relay_client()

relay_Signal.WaitAndExpect("agent not respond", 1)
Expand Down

0 comments on commit 472fc9f

Please sign in to comment.