MediaSfu_MediaSoup-client- flutter is not firing producerTransport "connect" method !!

Hi @Sam15b, I have hosted the backend in AWS EC2 but still i am getting this error from your cloned repo , i did not change the create transport, produce transport

After hosting again i tried through my phone and one from web ,Could you please check your pushed code again?

Just copy my repo will not gone work i am running backend server in my EC2 Instance which is running.
you can check the connects of Mediasoup
Do you add your Elastic ip in announcedIp SECTION
const webRtcTransport_options = {
listenIps: [
{
ip: ‘0.0.0.0’, // replace with relevant IP address
announcedIp: your ELASTIC IP ADDRESS HERE,
}
],
enableUdp: true,
enableTcp: true,
preferUdp: true,
}

Also what did you added in your security group of EC2

@Sam15b I just hosted your backend folder in EC2 instance, nothing else and got above error

Basically, i have also written the same backend on locally, on web it is working fine but when i try to connect with the flutter app it is unable to consume the other stream like similar case which i faced in your cloned repo

I am stuck at this step in my code, thats why i try to give a shot on your code to get a reference like in which stage it is lacking off

I have no issues with your post/comment; the duplication issue was directed towards the original poster; sorry for the miscommunication.

Regarding the screen sharing issue, it should probably be more about your permissions issue than the mediasoup client, so I can’t really help much with that. See if this (FOREGROUND_SERVICE_MEDIA_PROJECTION not found in io.agora.rtc2.extensions.MediaProjectionMgr$LocalScreenCaptureAssistantActivity on Android 14 · Issue #1733 · AgoraIO-Extensions/Agora-Flutter-SDK · GitHub) helps, or better still, make some more searches around foreground permissions in general.

@Sam15b , I have enable the udp and tcp for it, Do i need to add more security config?

I see that some of your snippets for your backend shared on GitHub are similar to MediaSFUOpen; if this is true (and even if otherwise), this is the reference for the MediaSFU Flutter SDK (MediaSFU_SDK_Flutter/lib/consumers/create_send_transport.dart at main · MediaSFU/MediaSFU_SDK_Flutter · GitHub), which also uses the mediasoup-client without any issues. Kindly check the highlighted (blue) links and see if there is any gap regarding your logic and the reference.

@Bdayz Yes i am familiar with these MFU files and yes it almost similar but in my recent issue using this package is that producer transport is connected but producer Transport ‘produce’ is not firing but on the other hand the frontend web it is working

By the way the backend code is running on locally through my system

Great. I am trying to say that your solution potentially lies within one of those highlighted files.

You are in the best position to check what is wrong by logging and analysing with the help of the reference. In summary, copy the relevant parts and maybe ask an LLM (say Gemini or Chatgpt, …) if ‘A’ works, why does ‘B’ not work.

Also, you can try to match all working implementations in the reference, then tune to match your style.

The key part is to ensure that all the data sent to the back is valid. Example is valid dtlsParameters sent, …

Thanks @Bdayz , i will try to backtrack on it again

Also @Sam15b thanks for clarifying my doubts, if so could you please help me in this issue

I have hosted my backend code which is similar to your one

In local the url opened for web is working fine but after hosting on AWS EC2 instance i find the user cant be able to consume the stream of other producer in web too which was working earlier in local

I have enable the udp for all in this case and the url that i got from AWS EC2 i am setting it up as announced ip

Do i need to add STUN or TURN server url too or it is fine ? Or Elastic Ip?

@Sam15b , Could you please elaborate what you changed in flutter and backend side , once you have hosted this server on AWS EC2 instance ? And also what did you configure in AWS to make sure there will be no firewall issue related to public ip?

And lastly did you add stun and turn server url in your backend code after hosting?

There is no mention of the STUN/TURN server unless for a few special cases, so I doubt that might be your reason. The MediaSFUOpen guide starts with ports and firewalls for media flow, IP configuration, and SSL stuff (certbot or self-signed) as you need that. So check these, and it should hopefully work.

Quick basic check: Are you running on SSL? Can you get a list of and request user media devices without getting a null/empty devices list? If yes, check your IP config first, then maybe ports. Else, check your SSL stuff.

Hi Everyone, @Sam15b

I have hosted the backend on AWS ec2 instance, i am able to consume the remote video stream of user in web frontend but somehow i am not able to receive in flutter app , please help anyone,
I have already added the elastic ip as announced ip in app js of backend folder

And in security config i have done tcp as 443, 80, 22 and udp as 10,000-20,000, 0-65,535 for now
PS: I am making sure udp will access all the connection , i will change it later on

on real device i got this

mediasoup-client:Device load() | got native RTP capabilities:Instance of ‘RtpCapabilities’
I/flutter ( 674): mediasoup-client:Device load() | got extended RTP capabilities:Instance of ‘ExtendedRtpCapabilities’
I/flutter ( 674): mediasoup-client:Device load() | got receiving RTP capabilities:Instance of ‘RtpCapabilities’
I/flutter ( 674): mediasoup-client:Native getNativeSctpCapabilities()
I/flutter ( 674): mediasoup-client:Device load() | got native SCTP capabilities:Instance of ‘SctpCapabilities’
I/flutter ( 674): mediasoup-client:Device load() successed
I/flutter ( 674): mediasoup-client:Native close()
I/flutter ( 674): Device RTP Capabilities: Instance of ‘RtpCapabilities’
I/flutter ( 674): existingPeers [{socketId: yPyx96nCoM1ge0MdAAAP, peerDetails: {name: Mutku, device: web, isAdmin: false}, producerId: 28f3da97-3335-4906-a2b5-2b1d6bbb1c46}, {socketId: T4Kb9-azxHjv9izcAAAR, peerDetails: {name: Hemant, device: web, isAdmin: false}, producerId: }]
I/flutter ( 674): Entering Into CreateSendTransport ---------
I/flutter ( 674): Found existing peer: yPyx96nCoM1ge0MdAAAP, setting up consumer
I/flutter ( 674): Peer details: {name: Mutku, device: web, isAdmin: false}
I/flutter ( 674): Peer details checking name: Mutku
I/flutter ( 674): Existing User added: [{username: fhgff, socketId: iO2UwNKSyt1HGEQgAAAT, Device: phone, videoRenderer: Instance of ‘RTCVideoRenderer’, AudioRenderer: Instance of ‘RTCVideoRenderer’, screenShareRenderer: Instance of ‘RTCVideoRenderer’, hasScreenSharingOn: false}, {username: Mutku, socketId: yPyx96nCoM1ge0MdAAAP, Device: web, videoRenderer: Instance of ‘RTCVideoRenderer’, AudioRenderer: Instance of ‘RTCVideoRenderer’, screenShareRenderer: Instance of ‘RTCVideoRenderer’, hasScreenSharingOn: false}]
I/flutter ( 674): ProducerId: 28f3da97-3335-4906-a2b5-2b1d6bbb1c46
I/flutter ( 674): signalNewConsumerTransport: 28f3da97-3335-4906-a2b5-2b1d6bbb1c46, yPyx96nCoM1ge0MdAAAP
I/flutter ( 674): Found existing peer: T4Kb9-azxHjv9izcAAAR, setting up consumer
I/flutter ( 674): Peer details: {name: Hemant, device: web, isAdmin: false}
I/flutter ( 674): Peer details checking name: Hemant
I/flutter ( 674): Existing User added: [{username: fhgff, socketId: iO2UwNKSyt1HGEQgAAAT, Device: phone, videoRenderer: Instance of ‘RTCVideoRenderer’, AudioRenderer: Instance of ‘RTCVideoRenderer’, screenShareRenderer: Instance of ‘RTCVideoRenderer’, hasScreenSharingOn: false}, {username: Mutku, socketId: yPyx96nCoM1ge0MdAAAP, Device: web, videoRenderer: Instance of ‘RTCVideoRenderer’, AudioRenderer: Instance of ‘RTCVideoRenderer’, screenShareRenderer: Instance of ‘RTCVideoRenderer’, hasScreenSharingOn: false}, {username: Hemant, socketId: T4Kb9-azxHjv9izcAAAR, Device: web, videoRenderer: Instance of ‘RTCVideoRenderer’, AudioRenderer: Instance of ‘RTCVideoRenderer’, screenShareRenderer: Instance of ‘RTCVideoRenderer’, hasScreenSharingOn: false}]
I/flutter ( 674): No ProducerId
I/flutter ( 674): checking for what refresh?existinguserupdate
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/org.webrtc.Logging( 674): EglRenderer: Initializing EglRenderer
I/org.webrtc.Logging( 674): EglRenderer: EglBase.create shared context
I/org.webrtc.Logging( 674): EglBase14Impl: Using OpenGL ES version 2
I/org.webrtc.Logging( 674): EglRenderer: Initializing EglRenderer
I/org.webrtc.Logging( 674): EglRenderer: EglBase.create shared context
I/org.webrtc.Logging( 674): EglBase14Impl: Using OpenGL ES version 2
I/gralloc4( 674): register: id=25a00035411, vaddr=0x740cc51000
I/gralloc4( 674): unregister: id=25a0003540e, vaddr=0x71e874f000
I/flutter ( 674): CalllBack Complish
params-id: f96ffd3c-20e6-48d6-83de-bb0eae6dcf4c
I/flutter ( 674): params-iceParameters: {usernameFragment:
rg9y1hdoqtw6n93pstunemuxn2db8mc6, password: 5erknnb6kbmklfxjyvkh0ksblwztysmk, iceLite: true}
I/flutter ( 674): params-iceCandidates: [{foundation: udpcandidate, priority: 1076302079, ip: 13.203.242.139, address: 13.203.242.139, protocol: udp, port: 2010, type: host}, {foundation: tcpcandidate, priority: 1076276479, ip: 13.203.242.139, address: 13.203.242.139, protocol: tcp, port: 2000, type: host, tcpType: passive}]
I/flutter ( 674): params-dtlsParameters: {fingerprints: [{algorithm: sha-1, value: C0:F8:20:6C:8E:61:C3:6C:5D:4E:1D:A9:13:F3:3E:63:04:CD:74:E7}, {algorithm: sha-384, value: 43:65:6B:AD:9D:C7:17:15:9F:3C:97:0C:A6:98:30:AB:59:A1:A2:1E:6F:CA:40:2F:F9:5B:08:C6:D0:28:2A:C1:0B:A8:F9:54:46:B1:F7:08:C0:99:BC:04:95:63:29:05}, {algorithm: sha-224, value: 0F:BA:40:0F:39:71:4E:CE:BD:1C:71:B0:D5:6C:F6:8C:60:35:6A:F9:64:FD:61:33:21:94:EF:4B}, {algorithm: sha-256, value: 1A:65:6E:37:4C:F3:40:2D:45:73:E2:26:CA:8B:EB:E4:68:67:4D:52:7D:B2:87:08:8B:FB:42:AD:D0:1A:41:3D}, {algorithm: sha-512, value: B6:FB:26:94:69:6A:23:F1:3E:64:AA:6E:BA:B4:F2:81:9D:B2:25:21:DA:F6:A4:AF:28:53:D3:AF:9C:31:12:D1:51:A2:08:7D:44:13:07:6D:D8:41:9C:95:4E:B1:C8:B2:2B:16:5A:18:4A:7E:B6:D4:02:93:DD:B8:9B:8F:31:AB}], role: auto}
I/flutter ( 674): mediasoup-client:Device createSendTransport()
I/flutter ( 674): mediasoup-client:Transport constructor() [id:f96ffd3c-20e6-48d6-83de-bb0eae6dcf4c, direction:send]
I/flutter ( 674): mediasoup-client:Native run()
D/MediaConstraintsUtils( 674): mandatory constraints are not a map
I/flutter ( 674): sendTransport Instance of ‘Transport’
I/flutter ( 674): Received transport params: {params: {id: 39ae2604-b873-4f8c-a641-ca2162744121, iceParameters: {usernameFragment: dyx9tcu1wuj1b1wh2zeuuxvidro60256, password: r47jvy0zegtv9jyfklowwz1sn9mkig7c, iceLite: true}, iceCandidates: [{foundation: udpcandidate, priority: 1076302079, ip: 13.203.242.139, address: 13.203.242.139, protocol: udp, port: 2019, type: host}, {foundation: tcpcandidate, priority: 1076276479, ip: 13.203.242.139, address: 13.203.242.139, protocol: tcp, port: 2006, type: host, tcpType: passive}], dtlsParameters: {fingerprints: [{algorithm: sha-1, value: C0:F8:20:6C:8E:61:C3:6C:5D:4E:1D:A9:13:F3:3E:63:04:CD:74:E7}, {algorithm: sha-384, value: 43:65:6B:AD:9D:C7:17:15:9F:3C:97:0C:A6:98:30:AB:59:A1:A2:1E:6F:CA:40:2F:F9:5B:08:C6:D0:28:2A:C1:0B:A8:F9:54:46:B1:F7:08:C0:99:BC:04:95:63:29:05}, {algorithm: sha-224, value: 0F:BA:40:0F:39:71:4E:CE:BD:1C:71:B0:D5:6C:F6:8C:60:35:6A:F9:64:FD:61:33:21:94:EF:4B}, {algorithm: sha-256, value: 1A:65:6E:37:4C:F3:40:2D:45:73:E2:26:CA:8B:EB:E4:68:67:4D:52:7D:B2:87:08:8B:FB
I/flutter ( 674): signalNewConsumerTransport Params:
I/flutter ( 674): signalNewConsumerTransport params-id: 39ae2604-b873-4f8c-a641-ca2162744121
I/flutter ( 674): signalNewConsumerTransport params-iceParameters: {usernameFragment: dyx9tcu1wuj1b1wh2zeuuxvidro60256, password: r47jvy0zegtv9jyfklowwz1sn9mkig7c, iceLite: true}
I/flutter ( 674): signalNewConsumerTransport params-iceCandidates: [{foundation: udpcandidate, priority: 1076302079, ip: 13.203.242.139, address: 13.203.242.139, protocol: udp, port: 2019, type: host}, {foundation: tcpcandidate, priority: 1076276479, ip: 13.203.242.139, address: 13.203.242.139, protocol: tcp, port: 2006, type: host, tcpType: passive}]
I/flutter ( 674): signalNewConsumerTransport params-dtlsParameters: {fingerprints: [{algorithm: sha-1, value: C0:F8:20:6C:8E:61:C3:6C:5D:4E:1D:A9:13:F3:3E:63:04:CD:74:E7}, {algorithm: sha-384, value: 43:65:6B:AD:9D:C7:17:15:9F:3C:97:0C:A6:98:30:AB:59:A1:A2:1E:6F:CA:40:2F:F9:5B:08:C6:D0:28:2A:C1:0B:A8:F9:54:46:B1:F7:08:C0:99:BC:04:95:63:29:05}, {algorithm: sha-224, value: 0F:BA:40:0F:39:71:4E:CE:BD:1C:71:B0:D5:6C:F6:8C:60:35:6A:F9:64:FD:61:33:21:94:EF:4B}, {algorithm: sha-256, value: 1A:65:6E:37:4C:F3:40:2D:45:73:E2:26:CA:8B:EB:E4:68:67:4D:52:7D:B2:87:08:8B:FB:42:AD:D0:1A:41:3D}, {algorithm: sha-512, value: B6:FB:26:94:69:6A:23:F1:3E:64:AA:6E:BA:B4:F2:81:9D:B2:25:21:DA:F6:A4:AF:28:53:D3:AF:9C:31:12:D1:51:A2:08:7D:44:13:07:6D:D8:41:9C:95:4E:B1:C8:B2:2B:16:5A:18:4A:7E:B6:D4:02:93:DD:B8:9B:8F:31:AB}], role: auto}
I/flutter ( 674): mediasoup-client:Device createRecvTransport()
I/flutter ( 674): mediasoup-client:Transport constructor() [id:39ae2604-b873-4f8c-a641-ca2162744121, direction:recv]
I/flutter ( 674): mediasoup-client:Native run()
I/flutter ( 674): cusmerTransport 39ae2604-b873-4f8c-a641-ca2162744121
I/flutter ( 674): Connecting recv transport to peer: yPyx96nCoM1ge0MdAAAP , 28f3da97-3335-4906-a2b5-2b1d6bbb1c46
I/flutter ( 674): --Entr into connectRecvTransport— 39ae2604-b873-4f8c-a641-ca2162744121
D/MediaConstraintsUtils( 674): mandatory constraints are not a map
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
Consumer Params: {id: a19ab750-5885-4a48-a728-2114d159816e, producerId: 28f3da97-3335-4906-a2b5-2b1d6bbb1c46, kind: video, rtpParameters: {codecs: [{mimeType: video/VP8, payloadType: 101, clockRate: 90000, parameters: {}, rtcpFeedback: [{type: ccm, parameter: fir}, {type: nack, parameter: }, {type: nack, parameter: pli}]}, {mimeType: video/rtx, payloadType: 102, clockRate: 90000, parameters: {apt: 101}, rtcpFeedback: }], headerExtensions: , encodings: [{ssrc: 245338486, rtx: {ssrc: 245338487}}], rtcp: {cname: 8u4fLy2tcAvqFW/d, reducedSize: true}, mid: 0}, serverConsumerId: a19ab750-5885-4a48-a728-2114d159816e, Source: camera, device: phone, Peername: , PeerId: }
I/flutter ( 674): Response id check a19ab750-5885-4a48-a728-2114d159816e
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/org.webrtc.Logging( 674): EglRenderer: Duration: 4034 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/org.webrtc.Logging( 674): EglRenderer: Duration: 4005 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/org.webrtc.Logging( 674): EglRenderer: Duration: 4004 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/org.webrtc.Logging( 674): EglRenderer: Duration: 4005 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
2
I/org.webrtc.Logging( 674): EglRenderer: Duration: 4005 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/org.webrtc.Logging( 674): EglRenderer: Duration: 4006 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
I/org.webrtc.Logging( 674): EglRenderer: Duration: 4005 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/flutter ( 674): check the height of the card: 253.33333333333334
I/flutter ( 674): checking the child Aspect ratio 1.5210526315789474
2
I/org.webrtc.Logging( 674): EglRenderer: Duration: 4005 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.

Hey, @Sam15b @Bdayz @ibc everyone,Could you please answer my below query
What all networking config have you done on EC2 instance to allow the flutter app which is based on webrtc and backend which is working on mediasoup architecture?

In webfrontend the remote user can see other video stream but on flutter i am getting ice candidate as failed even i have disable all security and open all the port for it in AWS ec2

Hi, are you able to solve this issue eventually. I also reached a blocker at the point of consuming the videotracks from the server. My flutter app is showing blanck screen while the localstream is rendering well.

Thanks in advance.

Solution here for future reference. Transport on 'connect' is never getting fired · Issue #2 · MediaSFU/mediasfu_mediasoup_client · GitHub