mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2026-03-14 14:35:44 +01:00
Reconnect proxy connection even if shutdown was scheduled before.
This commit is contained in:
parent
e027c484bd
commit
6956df67c8
2 changed files with 40 additions and 10 deletions
10
mcu_proxy.go
10
mcu_proxy.go
|
|
@ -759,11 +759,6 @@ func (c *mcuProxyConnection) scheduleReconnect() {
|
|||
}
|
||||
c.close()
|
||||
|
||||
if c.IsShutdownScheduled() {
|
||||
c.proxy.removeConnection(c)
|
||||
return
|
||||
}
|
||||
|
||||
interval := c.reconnectInterval.Load()
|
||||
// Prevent all servers from reconnecting at the same time in case of an
|
||||
// interrupted connection to the proxy or a restart.
|
||||
|
|
@ -812,11 +807,6 @@ func (c *mcuProxyConnection) reconnect() {
|
|||
return
|
||||
}
|
||||
|
||||
if c.IsShutdownScheduled() {
|
||||
c.proxy.removeConnection(c)
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Connected to %s", c)
|
||||
c.closed.Store(false)
|
||||
c.helloProcessed.Store(false)
|
||||
|
|
|
|||
|
|
@ -2501,6 +2501,46 @@ func Test_ProxyReconnectAfter(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func Test_ProxyReconnectAfterShutdown(t *testing.T) {
|
||||
CatchLogForTest(t)
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
server := NewProxyServerForTest(t, "DE")
|
||||
mcu, _ := newMcuProxyForTestWithOptions(t, proxyTestOptions{
|
||||
servers: []*TestProxyServerHandler{server},
|
||||
}, 0)
|
||||
|
||||
connections := mcu.getSortedConnections(nil)
|
||||
require.Len(connections, 1)
|
||||
sessionId := connections[0].SessionId()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
|
||||
defer cancel()
|
||||
|
||||
client := server.GetSingleClient()
|
||||
require.NotNil(client)
|
||||
|
||||
client.sendMessage(&ProxyServerMessage{
|
||||
Type: "event",
|
||||
Event: &EventProxyServerMessage{
|
||||
Type: "shutdown-scheduled",
|
||||
},
|
||||
})
|
||||
|
||||
// Force reconnect.
|
||||
client.close()
|
||||
assert.NoError(mcu.WaitForDisconnected(ctx))
|
||||
|
||||
// The client will automatically reconnect and resume the session.
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
assert.NoError(mcu.WaitForConnections(ctx))
|
||||
|
||||
if connections := mcu.getSortedConnections(nil); assert.Len(connections, 1) {
|
||||
assert.Equal(sessionId, connections[0].SessionId())
|
||||
}
|
||||
}
|
||||
|
||||
func Test_ProxyResume(t *testing.T) {
|
||||
CatchLogForTest(t)
|
||||
t.Parallel()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue