outpost: add additional checks for websocket connection

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-12-11 23:44:49 +01:00
parent 1486f90077
commit 4982c4abcb
2 changed files with 11 additions and 1 deletions

View File

@ -116,6 +116,11 @@ func (ac *APIController) startWSHandler() {
logger := ac.logger.WithField("loop", "ws-handler")
for {
var wsMsg websocketMessage
if ac.wsConn == nil {
go ac.reconnectWS()
time.Sleep(time.Second * 5)
continue
}
err := ac.wsConn.ReadJSON(&wsMsg)
if err != nil {
ConnectionStatus.With(prometheus.Labels{
@ -163,6 +168,11 @@ func (ac *APIController) startWSHealth() {
"uuid": ac.instanceUUID.String(),
},
}
if ac.wsConn == nil {
go ac.reconnectWS()
time.Sleep(time.Second * 5)
continue
}
err := ac.wsConn.WriteJSON(aliveMsg)
ac.logger.WithField("loop", "ws-health").Trace("hello'd")
if err != nil {

View File

@ -158,7 +158,7 @@ class TestProviderProxyConnect(ChannelsLiveServerTestCase):
sleep(0.5)
state = outpost.state
self.assertEqual(len(state), 1)
self.assertTrue(len(state) >= 1)
self.assertEqual(state[0].version, __version__)
# Make sure to delete the outpost to remove the container