Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection Failed when upgrading to newest version (2.5.2 - 2.5.7) #1723

Open
padi-dev-anhntn opened this issue Feb 21, 2025 · 10 comments
Open

Comments

@padi-dev-anhntn
Copy link

padi-dev-anhntn commented Feb 21, 2025

Hi,
I use 2.5.1 and it works well, I start streaming from mobile and can see the video streaming on the website.
I want to upgrade to newer version(2.5.2 - 2.5.7) to remove the noise when streaming using rtmpStream.setTimestampMode(TimestampMode.BUFFER, TimestampMode.BUFFER);
But when I upgrade to newer version, it had errors like this, and I can't see the video streaming on the website.
'rtmps://abc-live-20-01-abcd.rtmp.livekit.cloud/x/abcdef'

/Handshake( 6589): writing C0
I/Handshake( 6589): C0 write successful
I/Handshake( 6589): writing C1
I/Handshake( 6589): writing time 1740476260 to c1
I/Handshake( 6589): writing zero to c1
I/Handshake( 6589): writing random to c1
I/Handshake( 6589): C1 write successful
I/Handshake( 6589): reading S0
I/Handshake( 6589): read S0 successful
I/Handshake( 6589): reading S1
E/RtmpClient( 6589): connection error
E/RtmpClient( 6589): kotlinx.coroutines.channels.ClosedReceiveChannelException: Unexpected EOF: expected 1434 more bytes
E/RtmpClient( 6589): 	at io.ktor.utils.io.ByteBufferChannel.readFullySuspend(ByteBufferChannel.kt:623)
E/RtmpClient( 6589): 	at io.ktor.utils.io.ByteBufferChannel.access$readFullySuspend(ByteBufferChannel.kt:23)
E/RtmpClient( 6589): 	at io.ktor.utils.io.ByteBufferChannel$readFullySuspend$3.invokeSuspend(Unknown Source:16)
E/RtmpClient( 6589): 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/RtmpClient( 6589): 	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
E/RtmpClient( 6589): 	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
E/RtmpClient( 6589): 	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
E/RtmpClient( 6589): 	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
E/RtmpClient( 6589): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
E/RtmpClient( 6589): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
E/RtmpClient( 6589): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)
E/duc2111 ( 6589): onConnectionFailed = Error configure stream, Unexpected EOF: expected 1434 more bytes
W/VideoCapabilities( 6589): Unrecognized profile 2130706433 for video/avc
W/VideoCapabilities( 6589): Unrecognized profile 2130706434 for video/avc
W/VideoCapabilities( 6589): Unrecognized profile 2130706433 for video/avc
W/VideoCapabilities( 6589): Unrecognized profile 2130706434 for video/avc
W/VideoCapabilities( 6589): Unrecognized profile 2130706433 for video/avc
W/VideoCapabilities( 6589): Unrecognized profile 2130706434 for video/avc
W/VideoCapabilities( 6589): Unrecognized profile 2130706433 for video/avc
W/VideoCapabilities( 6589): Unrecognized profile 2130706434 for video/avc
D/FlutterWebRTCPlugin( 6589): onIceGatheringChangeGATHERING
D/FlutterWebRTCPlugin( 6589): onIceCandidate
I/chatty  ( 6589): uid=10950(app.boosty.live.boosty_live_app.stg) signaling_threa identical 4 lines
2
D/FlutterWebRTCPlugin( 6589): onIceCandidate
I/chatty  ( 6589): uid=10950(app.boosty.live.boosty_live_app.stg) signaling_threa identical 1 line
2
D/FlutterWebRTCPlugin( 6589): onIceCandidate
I/chatty  ( 6589): uid=10950(app.boosty.live.boosty_live_app.stg) signaling_threa identical 1 line
5
D/FlutterWebRTCPlugin( 6589): onIceCandidate
2
I/flutter ( 6589): isCameraOn camera - true
W/FlutterWebRTCPlugin( 6589): audioFocusChangeListener [Earpiece(name=Earpiece)] Earpiece(name=Earpiece)
W/FlutterWebRTCPlugin( 6589): audioFocusChangeListener [Speakerphone(name=Speakerphone), Earpiece(name=Earpiece)] Speakerphone(name=Speakerphone)
D/MediaConstraintsUtils( 6589): mandatory constraints are not a map
D/MediaConstraintsUtils( 6589): optional constraints are not an array
D/FlutterWebRTCPlugin( 6589): onConnectionChangeCONNECTING
D/FlutterWebRTCPlugin( 6589): onSelectedCandidatePairChanged
D/FlutterWebRTCPlugin( 6589): onIceGatheringChangeCOMPLETE
D/FlutterWebRTCPlugin( 6589): onConnectionChangeCONNECTED
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: initRecording(sampleRate=48000, channels=1)
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: byteBuffer.capacity: 960
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: AudioRecord.getMinBufferSize: 3840
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: bufferSizeInBytes: 7680
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: createAudioRecordOnMOrHigher
W/AudioRecord( 6589): dead IAudioRecord, creating a new one from obtainBuffer()
I/org.webrtc.Logging( 6589): WebRtcAudioEffectsExternal: enable(audioSession=52489)
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: AudioRecord: session ID: 52489, channels: 1, sample rate: 48000
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: AudioRecord: buffer size in frames: 3840
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: Number of active recording sessions: 0
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: startRecording
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: scheduleLogRecordingConfigurationsTask
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: AudioRecordThread@[name=AudioRecordJavaThread, id=18174]
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: doAudioRecordStateCallback: START
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: Number of active recording sessions: 2
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: AudioRecordingConfigurations: 
E/AudioRecordingConfiguration( 6589): Couldn't find device for recording, did recording end already?
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal:   client audio source=MIC, client session id=52481 (52489)
I/org.webrtc.Logging( 6589):   Device AudioFormat: channel count=1, channel index mask=0, channel mask=IN_MONO, encoding=PCM_16BIT, sample rate=48000
I/org.webrtc.Logging( 6589):   Client AudioFormat: channel count=2, channel index mask=0, channel mask=IN_STEREO, encoding=PCM_16BIT, sample rate=32000
E/AudioRecordingConfiguration( 6589): Couldn't find device for recording, did recording end already?
I/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal:   client audio source=VOICE_COMMUNICATION, client session id=52489 (52489)
I/org.webrtc.Logging( 6589):   Device AudioFormat: channel count=1, channel index mask=0, channel mask=IN_MONO, encoding=PCM_16BIT, sample rate=48000
I/org.webrtc.Logging( 6589):   Client AudioFormat: channel count=1, channel index mask=0, channel mask=IN_MONO, encoding=PCM_16BIT, sample rate=48000
2
E/AudioRecordingConfiguration( 6589): Couldn't find device for recording, did recording end already?
E/org.webrtc.Logging( 6589): WebRtcAudioRecordExternal: verifyAudioConfig: FAILED

My initialization:

rtmpStream = new RtmpStream(activity, this, videoSource, new MicrophoneSource());
rtmpStream.getGlInterface().setAutoHandleOrientation(true);
rtmpStream.getStreamClient().setBitrateExponentialFactor(0.5f);
rtmpStream.setTimestampMode(TimestampMode.BUFFER, TimestampMode.BUFFER);

rtmpStream.prepareAudio(32000, true, 128 * 1000);
rtmpStream.prepareVideo(1280, 720, 1200* 1000);

 rtmpStream.startStream('rtmps://abc-live-20-01-abcd.rtmp.livekit.cloud/x/abcdef');

 rtmpStream.getGlInterface().setIsPortrait(true);
 rtmpStream.getGlInterface().setCameraOrientation(0);
 rtmpStream.startPreview(surface, resolutionPreset.getHeight(), resolutionPreset.getWidth());

Thanks.

@padi-dev-anhntn padi-dev-anhntn changed the title Error streaming when upgrading to 2.5.2 Error streaming when upgrading to newest version Feb 25, 2025
@padi-dev-anhntn padi-dev-anhntn changed the title Error streaming when upgrading to newest version Connection Failed when upgrading to newest version Feb 25, 2025
@padi-dev-anhntn padi-dev-anhntn changed the title Connection Failed when upgrading to newest version Connection Failed when upgrading to newest version (2.5.2 - 2.5.7) Feb 27, 2025
@pedroSG94
Copy link
Owner

Hello,

I'm testing using that url with version 2.5.7 and version 2.5.1 and I receive the same error. Can you share a valid url to test?
Maybe it is related with the server so I need the same server to reproduce it or a way to configure the server like you to reproduce the error.

@padi-dev-anhntn
Copy link
Author

padi-dev-anhntn commented Feb 28, 2025

Hi @pedroSG94 ,
Wait for me to configure the valid url to you.
But is it any way related to Url Parser?
Here's format of the url
rtmps://abc-live-dev-aBCDef1gH.rtmp.livekit.cloud/x/aBcd1EfG2H

And it didn't work from this commit.
be98bef
Thanks.

@padi-dev-anhntn
Copy link
Author

Hi @pedroSG94 ,

Update:
I use rtmp:// instead of rtmps:// and it works on 2.5.2 - 2.5.7
But I still want to use rtmps://

Thanks.

@pedroSG94
Copy link
Owner

Hello,

It is maybe related with ktor. Can you test with master branch which contain an update of ktor? compile the project and use the last commit.

@pedroSG94
Copy link
Owner

But is it any way related to Url Parser?

No, if it is working with rtmp the parser is working correctly

@padi-dev-anhntn
Copy link
Author

padi-dev-anhntn commented Feb 28, 2025

Hi @pedroSG94 ,
I tried last commit acdb4be

it shows connection error java.io.EOFException: Channel is already closed

I/Handshake( 4851): writing C0
I/Handshake( 4851): C0 write successful
I/Handshake( 4851): writing C1
I/Handshake( 4851): writing time 1740736706 to c1
I/Handshake( 4851): writing zero to c1
I/Handshake( 4851): writing random to c1
I/Handshake( 4851): C1 write successful
I/Handshake( 4851): reading S0
W/VideoCapabilities( 4851): Unrecognized profile 2130706433 for video/avc
W/VideoCapabilities( 4851): Unrecognized profile 2130706434 for video/avc
W/VideoCapabilities( 4851): Unrecognized profile 2130706433 for video/avc
W/VideoCapabilities( 4851): Unrecognized profile 2130706434 for video/avc
W/VideoCapabilities( 4851): Unrecognized profile 2130706433 for video/avc
W/VideoCapabilities( 4851): Unrecognized profile 2130706434 for video/avc
W/VideoCapabilities( 4851): Unrecognized profile 2130706433 for video/avc
W/VideoCapabilities( 4851): Unrecognized profile 2130706434 for video/avc
I/Handshake( 4851): read S0 successful
I/Handshake( 4851): reading S1
D/FlutterWebRTCPlugin( 4851): onIceGatheringChangeGATHERING
D/FlutterWebRTCPlugin( 4851): onIceCandidate
I/chatty  ( 4851): uid=10952(app.boosty.live.boosty_live_app.stg) signaling_threa identical 3 lines
2
D/FlutterWebRTCPlugin( 4851): onIceCandidate
E/RtmpClient( 4851): connection error
E/RtmpClient( 4851): java.io.EOFException: Channel is already closed
E/RtmpClient( 4851): 	at io.ktor.utils.io.ByteReadChannelOperationsKt.readFully(ByteReadChannelOperations.kt:523)
E/RtmpClient( 4851): 	at io.ktor.utils.io.ByteReadChannelOperationsKt$readFully$1.invokeSuspend(Unknown Source:14)
E/RtmpClient( 4851): 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/RtmpClient( 4851): 	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
E/RtmpClient( 4851): 	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
E/RtmpClient( 4851): 	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
E/RtmpClient( 4851): 	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
E/RtmpClient( 4851): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
E/RtmpClient( 4851): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
E/RtmpClient( 4851): 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)
E/onConnectionFailed ( 4851): onConnectionFailed = Error configure stream, Channel is already closed
3
D/FlutterWebRTCPlugin( 4851): onIceCandidate
I/chatty  ( 4851): uid=10952(app.boosty.live.boosty_live_app.stg) signaling_threa identical 1 line
4
D/FlutterWebRTCPlugin( 4851): onIceCandidate
I/flutter ( 4851): isCameraOn camera - true
2
D/FlutterWebRTCPlugin( 4851): onIceCandidate
W/FlutterWebRTCPlugin( 4851): audioFocusChangeListener [Earpiece(name=Earpiece)] Earpiece(name=Earpiece)
W/FlutterWebRTCPlugin( 4851): audioFocusChangeListener [Speakerphone(name=Speakerphone), Earpiece(name=Earpiece)] Speakerphone(name=Speakerphone)
D/MediaConstraintsUtils( 4851): mandatory constraints are not a map
D/MediaConstraintsUtils( 4851): optional constraints are not an array

@pedroSG94
Copy link
Owner

Can you share me a valid endpoint to connect? I'm no able to connect using the old version 2.5.1

@pedroSG94
Copy link
Owner

I was able to create my own livekit server and reproduce the problem. I will work in this and release a fix

@padi-dev-anhntn
Copy link
Author

Thank you so much ♥️

@pedroSG94
Copy link
Owner

Hello,

I'm working in this but this seem a bug in ktor using tls socket. I can fix the problem using java.io blocking api for socket like before but this could have others problems blocking the send sometimes. I'm looking the best way to do it but I'm not sure how to do it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants