Open mustafaboleken opened 1 month ago
For more info on this problem see the following: https://github.com/ant-media/Ant-Media-Server/issues/4071#issuecomment-2012348181
Hi @MaZZly
I just finished the implementation and it works for me. Can you please test it and tell me if it works for you or not?
Btw, other than these changes, you need to make a couple of configuration changes:
Go to the management console, edit advanced settings, and set "encodingTimeout": 500
, "webRTCClientStartTimeoutMs": 1000
Also, you mentioned about the newTrackAvailable
is not received after ice connection change. To be able to receive the latest tracks, you can call requestVideoTrackAssignments(streamId)
function and you will get video_track_assignment_list and audio_track_assignment callbacks. Then, you can just update them.
@mustafaboleken we will go through it and see if it works as needed for network changes :)
@mustafaboleken it seems to be a bit better, but there are still cases where it stops working and seem to get into a "runaway" scenario where the console flooding with triggered events for reconnection_attempt_for_X/unathorized_access/already_playing.
By the way, we haven't needed or seen any events of the requestVideoTrackAssignments
or video_track_assignment_list
type yet.
pariticipant_desktop
, pariticipant2_desktop
and pariticipant3_mobile
(from e.g. Android phone)
After doing this for a while (and it seems after WebSocketNotConnected
has triggered a couple times) it will start to flood the console with more and more of the following:
reconnection_attempt_for_publisher
(multiple times for same streamid)reconnection_attempt_for_player
(multiple times for same streamid)Cannot send message:
WebSocketNotConnected
unauthorized_access
(hundreds of them for the same streamids)already_playing
(hundreds of them for the same streamids)So it seems there is something that starts spawning multiple calls when the websocket connection has been gone in to some state (multiple disconnects?) and from there just keeps spawning more and more events, creating a runaway scenario where no streaming works anymore and the device/tab ultimately becomes unusable.
One more thing, which I'm not 100% sure is related to the ANT JS SDK, but when this runaway scenario happens, it also seems to bring down the mobile connection on my Android 14 phone (OP10Pro).. It doesn't seem to happen while on Wifi. Could maybe be related to runaway scenario trying to open a bunch of new connections and my ISP therefore throttling the connection?
Hi @MaZZly
I will try the scenario you provided. Btw, can you tell me your ant media server version?
@mustafaboleken it is Enterprise Edition 2.9.0 20240405_1755
@mustafaboleken did some more testing with 2 participants, one streaming from mobile, and one watcher from desktop. This is probably the easiest I've been able to reproduce problems so far.
WebSocket connection to '...' failed: ...
publish_started
event to trigger
webRTCAdaptor.getRoomInfo(
triggers callback no_active_streams_in_room
) We have logic for killing the broadcast if streamIdInUse
triggers, but I also tried without and the same thing happens..
I also noticed that with the 1000ms setting, we are pretty often triggering publishTimeoutError
on the mobile client... Is that really needed/better than the 3000 default setting?
Note that the 1000ms timeout might be "okay" in your test setup, and not triggering the problem described above...
Anyway, there seems to be some timing issue somewhere, and the even though the server sees the newly started broadcast, it is not passed on to the other participants in the room. Is there somewhere in AMS UI where I can see if the broadcast is tied to a room?
Hi @MaZZly
When I think about these two things
By the way, we haven't needed or seen any events of the requestVideoTrackAssignments or video_track_assignment_list type yet.
and
Doing webRTCAdaptor.getRoomInfo( triggers callback no_active_streams_in_room
I realize that you are using a stream-based conference solution. I was doing my tests with the multitrack conference samples. Probably that's why I didn't face them.
Can you tell me which one you are using?
TBH I don't know (AMS documentation is quite scattered...), but from a quick Google it seems we should've used sdpSemantics
to enable multitrack, which we haven't.
So I'm going to say/guess we are just using stream-based solution.
@mustafaboleken webRTCAdaptor.playStreamId
still also has the problem of starting to contain duplicates (multiple ones) after doing network switches...
Edit: It even creates multiple double entries of same stream during one network switch... And also the "runaway"-problem described above seems to create very many instances of the same streamid... This could point to where the problem there is (if there are multiple ones "spawned" on every retry)
Maybe you already saw that but stream-based conferences are deprecated and most likely removed in the next version. Do you want to migrate to the multitrack conference? If you prefer it, I can help you to migrate quickly and the issues that you are reporting will be solved. Let me know how do you wanna proceed?
Well if the other one is deprecated I guess we should migrate... How do we proceed to get this done ASAP ?
@mustafaboleken also, is the track-based conference room supported by other SDKs than JS? :thinking: If not, when/are they planned?
We're mostly interested in the Flutter SDK timeline
Yes, the multitrack approach is supported by all of our SDKs. I can prepare a migration guide and send it to you or if you wanted to make a meeting, you can just contact me through my mail address so we can make it together. Other than my planned meetings, my first priority is solving your problem. Just let me know about your decision. @MaZZly
@mustafaboleken lets start with a guide, and if something is unclear we can do a meeting to go through the unclear details :)
Sure, I will prepare and send it to you in 2 hours. :)
Room Structure Removal:
Simplified Participant Management:
roomOfStream
or streamsList
as in the previous sample. Instead, you can check the subTracks of the main broadcasts. More details here.Storing Status in Metadata:
Function Simplification:
joinRoom
, leave
, and getRoomInfo
functions are no longer needed. All you need to do is publish to the main broadcast and play it. More details here.New Callbacks:
New Websocket Message:
getBroadcastObject
has been introduced to retrieve the Broadcast structure as JSON. This broadcast can be either a Maintrack or a Subtrack. Obtain a Broadcast object for a main track by calling getBroadcastObject
with the room ID, and for a subtrack, use its ID.Event-Based Approach:
getRoomInfo
method is no longer used. Instead, an event-based approach has been introduced. Applications will now be notified by the TRACK_LIST_UPDATED
Data Channel message. Upon receiving this notification, applications can call getBroadcastObject
for the Maintrack, check the subtracks, and obtain participant names by calling getBroadcastObject
for the participant ID.Also I have a pr to show how to implement reconnection mechanism into the sample, you can also take a look at that https://github.com/ant-media/StreamApp/pull/449 @MaZZly
@mustafaboleken I sent you a mail about setting up a chat :)
You can check the inbox. @MaZZly
Hi @MaZZly,
TBH I don't know (AMS documentation is quite scattered...), but from a quick Google it seems we should've used
sdpSemantics
to enable multitrack, which we haven't. So I'm going to say/guess we are just using stream-based solution.
I'm sorry you had to face problems with the documentation and couldn't find the right instructions while you were implementing the solution.
We are continuously trying to improve the documents and make them more useful and user-friendly.
It is already mentioned in the multitrack document that the sdpSemantics
should be set to Unified Plan which is also set by default in AMS v2.4.3 and above.
It seems like we are missing some pieces in the documents and it would be great if you can guide me so that it can improved further. May I know which specific document you looked at and what are the issues you face about the documentation so that we can improve the same?
Thank you, Mohit