diff --git a/backend/api.test/Mocks/IsarServiceMock.cs b/backend/api.test/Mocks/IsarServiceMock.cs index 15fe3c0f..111fa740 100644 --- a/backend/api.test/Mocks/IsarServiceMock.cs +++ b/backend/api.test/Mocks/IsarServiceMock.cs @@ -48,7 +48,7 @@ public async Task StartMoveArm(Robot robot, string position) return isarServiceMissionResponse; } - public async Task GetMediaStreamConfig(Robot robot) + public async Task GetMediaStreamConfig(Robot robot) { await Task.Run(() => Thread.Sleep(1)); return new MediaConfig diff --git a/backend/api/Controllers/MediaStreamController.cs b/backend/api/Controllers/MediaStreamController.cs index 8bfb4911..9d0e095c 100644 --- a/backend/api/Controllers/MediaStreamController.cs +++ b/backend/api/Controllers/MediaStreamController.cs @@ -28,7 +28,7 @@ IRobotService robotService [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> GetMediaStreamConfig([FromRoute] string id) + public async Task> GetMediaStreamConfig([FromRoute] string id) { try { diff --git a/backend/api/Services/IsarService.cs b/backend/api/Services/IsarService.cs index bbd567f5..f7926dee 100644 --- a/backend/api/Services/IsarService.cs +++ b/backend/api/Services/IsarService.cs @@ -19,7 +19,7 @@ public interface IIsarService public Task StartMoveArm(Robot robot, string armPosition); - public Task GetMediaStreamConfig(Robot robot); + public Task GetMediaStreamConfig(Robot robot); } public class IsarService( @@ -305,7 +305,7 @@ HttpResponseMessage response return (description, (int)statusCode); } - public async Task GetMediaStreamConfig(Robot robot) + public async Task GetMediaStreamConfig(Robot robot) { string mediaStreamPath = $"/media/media-stream-config"; var response = await CallApi(HttpMethod.Get, robot.IsarUri, mediaStreamPath); @@ -317,11 +317,13 @@ public async Task GetMediaStreamConfig(Robot robot) logger.LogError("{Message}: {ErrorResponse}", message, errorResponse); throw new ConfigException(message); } - if (response.Content is null) + + if (response.StatusCode == HttpStatusCode.NoContent) { - string errorMessage = "Could not read content from new robot media stream config"; - logger.LogError("{ErrorMessage}", errorMessage); - throw new ConfigException(errorMessage); + logger.LogDebug( + $"Robot with id {robot.Id} did not return any content for media stream config. This is likely because the robot doesn't have a media stream." + ); + return null; } IsarMediaConfigMessage? isarMediaConfigResponse; diff --git a/frontend/src/api/ApiCaller.tsx b/frontend/src/api/ApiCaller.tsx index d840eec8..9cf5c97f 100644 --- a/frontend/src/api/ApiCaller.tsx +++ b/frontend/src/api/ApiCaller.tsx @@ -141,7 +141,7 @@ export class BackendAPICaller { return result.content } - static async getRobotMediaConfig(robotId: string): Promise { + static async getRobotMediaConfig(robotId: string): Promise { const path: string = 'media-stream/' + robotId const result = await this.GET(path).catch(BackendAPICaller.handleError('GET', path)) return result.content diff --git a/frontend/src/components/Contexts/MediaStreamContext.tsx b/frontend/src/components/Contexts/MediaStreamContext.tsx index f20eea38..88dd70a3 100644 --- a/frontend/src/components/Contexts/MediaStreamContext.tsx +++ b/frontend/src/components/Contexts/MediaStreamContext.tsx @@ -143,7 +143,9 @@ export const MediaStreamProvider: FC = ({ children }) => { const refreshRobotMediaConfig = (robotId: string) => { BackendAPICaller.getRobotMediaConfig(robotId) - .then((conf: MediaStreamConfig) => addConfigToMediaStreams(conf)) + .then((conf: MediaStreamConfig | null | undefined) => { + if (conf) addConfigToMediaStreams(conf) + }) .catch((e) => console.error(e)) }