Skip to content

Commit

Permalink
Fixed retrying after mqtt disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkonst committed Mar 20, 2023
1 parent 0109a29 commit a37b1ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ulms/api-clients",
"version": "5.16.0",
"version": "5.16.1",
"description": "JavaScript API clients for ULMS platform",
"keywords": [],
"homepage": "https://github.com/foxford/ulms-api-clients-js#readme",
Expand Down
9 changes: 9 additions & 0 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export async function enterServiceRoom(
serviceName
) {
const EVENT_NAME = 'room.enter'
const isTransportConnected = () => client.mqtt.connected
let enterRoomSuccess = false
let response

Expand All @@ -82,9 +83,17 @@ export async function enterServiceRoom(
try {
// eslint-disable-next-line no-constant-condition
while (true) {
if (!isTransportConnected()) {
throw new Error('MQTT client disconnected')
}

// eslint-disable-next-line no-await-in-loop
response = await httpClient.enterRoom(roomId, label)

if (!isTransportConnected()) {
throw new Error('MQTT client disconnected')
}

if (enterRoomSuccess) break

// eslint-disable-next-line no-await-in-loop
Expand Down

0 comments on commit a37b1ce

Please sign in to comment.