diff --git a/react/src/__tests__/pages/AntMedia.test.js b/react/src/__tests__/pages/AntMedia.test.js
index 66480ef4..c6012406 100644
--- a/react/src/__tests__/pages/AntMedia.test.js
+++ b/react/src/__tests__/pages/AntMedia.test.js
@@ -2275,6 +2275,37 @@ describe('AntMedia Component', () => {
consoleSpy.mockRestore();
});
+ it('streamIdInUseCounter is not incremented due to reconnection is true', async () => {
+ const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
+
+ const {container} = render(
+
+
+
+
+ );
+
+
+ await waitFor(() => {
+ expect(webRTCAdaptorConstructor).not.toBe(undefined);
+ });
+
+ await act(async () => {
+ webRTCAdaptorConstructor.callback("reconnection_attempt_for_player");
+ });
+
+ await act(async () => {
+ webRTCAdaptorConstructor.callbackError("streamIdInUse", "Stream ID is in use");
+ webRTCAdaptorConstructor.callbackError("streamIdInUse", "Stream ID is in use");
+ webRTCAdaptorConstructor.callbackError("streamIdInUse", "Stream ID is in use");
+ webRTCAdaptorConstructor.callbackError("streamIdInUse", "Stream ID is in use");
+ });
+
+ expect(consoleSpy).not.toHaveBeenCalledWith("This stream id is already in use. You may be logged in on another device.");
+
+ consoleSpy.mockRestore();
+ });
+
it('updates allParticipants and participantUpdated when subtrackList is provided', async () => {
const { container } = render(
diff --git a/react/src/pages/AntMedia.js b/react/src/pages/AntMedia.js
index 6491cdf5..ed5da128 100644
--- a/react/src/pages/AntMedia.js
+++ b/react/src/pages/AntMedia.js
@@ -1797,13 +1797,16 @@ function AntMedia(props) {
} else if (error.indexOf("no_stream_exist") !== -1) {
setIsNoSreamExist(true);
} else if (error.indexOf("streamIdInUse") !== -1) {
- streamIdInUseCounter++;
- if (streamIdInUseCounter > 3) {
- console.log("This stream id is already in use. You may be logged in on another device.");
- setLeaveRoomWithError("Streaming is already active with your username. Please check that you're not using it in another browser tab.");
- setLeftTheRoom(true);
- setIsJoining(false);
- setIsReconnectionInProgress(false);
+ // if the stream id is in use when reconnection, don't display the error
+ if (!reconnecting) {
+ streamIdInUseCounter++;
+ if (streamIdInUseCounter > 3) {
+ console.log("This stream id is already in use. You may be logged in on another device.");
+ setLeaveRoomWithError("Streaming is already active with your username. Please check that you're not using it in another browser tab.");
+ setLeftTheRoom(true);
+ setIsJoining(false);
+ setIsReconnectionInProgress(false);
+ }
}
} else if (error.indexOf("data_channel_error") !== -1) {
errorMessage = "There was a error during data channel communication";