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

[Bug]: RTMP send error #39(54 bytes),RTMP send error #9 (42 bytes) #63

Open
2 tasks done
Ajmalnk1836 opened this issue Aug 5, 2024 · 7 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@Ajmalnk1836
Copy link

Version

v1.2.0

Which operating systems have you used?

  • Android
  • iOS

Environment that reproduces the issue

Google Pixel 6 (Android 12)
ATEX M5

Is it reproducible in the example application?

Yes

RTMP Server

rtmp://broadcast.api.video/s

Reproduction steps

Configured same as example application,

  1. configure audio with AudioConfig()
  2. Configure Video with VideoConfig.defaultBitrate()
  3. start streaming - .startStreaming(streamKey: config.streamKey, url: config.rtmpUrl)

Expected result

The RTMP server could receive the video stream correctly without any interruption.

Actual result

Start stream worked successfully without any interruption, but after some time, middle of streaming time, disconnect event was reported after seconds, throwing errors like 'RTMP send error #39 (54 bytes),RTMP send error #9 (42 bytes)', also phone got freezed,
The same issue I had faced in the example application. 
Since two weeks ago, I have been facing this issue. I could not get what the actual root cause of this issue is. It could be better if someone provided the solution. Thanks
The error looks like this:

I/        (21871): Format changed : {max-bitrate=2000000, crop-right=719, level=512, mime=video/avc, profile=8, bitrate=2000000, priority=0, intra-refresh-period=0, color-standard=1, csd-1=java.nio.HeapByteBuffer[pos=0 lim=8 cap=8], color-transfer=3, crop-bottom=1279, prepend-sps-pps-to-idr-frames=0, crop-left=0, width=720, bitrate-mode=1, color-range=2, crop-top=0, frame-rate=30, height=1280, csd-0=java.nio.HeapByteBuffer[pos=0 lim=21 cap=21]}
E/rtmpdroid(21871): WriteN, RTMP send error 104 (12 bytes)
E/rtmpdroid(21871): WriteN, RTMP send error 32 (71 bytes)
E/rtmpdroid(21871): WriteN, RTMP send error 9 (42 bytes)
E/RtmpProducer(21871): Error while writing packet to socket
E/RtmpProducer(21871): java.net.SocketException: Connection error
E/RtmpProducer(21871): 	at video.api.rtmpdroid.Rtmp.write(Rtmp.kt:139)
E/RtmpProducer(21871): 	at io.github.thibaultbee.streampack.ext.rtmp.internal.endpoints.RtmpProducer.write(RtmpProducer.kt:94)
E/RtmpProducer(21871): 	at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$muxListener$1.onOutputFrame(BaseStreamer.kt:132)
E/RtmpProducer(21871): 	at io.github.thibaultbee.streampack.internal.muxers.flv.FlvMuxer.encode(FlvMuxer.kt:77)
E/RtmpProducer(21871): 	at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$videoEncoderListener$1.onOutputFrame(BaseStreamer.kt:120)
E/RtmpProducer(21871): 	at io.github.thibaultbee.streampack.internal.encoders.MediaCodecEncoder$encoderCallback$1.onOutputBufferAvailable(MediaCodecEncoder.kt:109)
E/RtmpProducer(21871): 	at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1845)
E/RtmpProducer(21871): 	at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1743)
E/RtmpProducer(21871): 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/RtmpProducer(21871): 	at android.os.Looper.loopOnce(Looper.java:201)
E/RtmpProducer(21871): 	at android.os.Looper.loop(Looper.java:288)
E/RtmpProducer(21871): 	at android.os.HandlerThread.run(HandlerThread.java:67)

Additional context

[!] Flutter (Channel [user-branch], 3.19.5, on Microsoft Windows [Version 10.0.22631.3880], locale en-US)
    ! Flutter version 3.19.5 on channel [user-branch] at C:\src\flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at
      https://flutter.dev/docs/get-started/install.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision 300451adae (4 months ago), 2024-03-27 21:54:07 -0500
    • Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly
      to perform update checks and upgrades.

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\muhammed\AppData\Local\Android\sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe



[√] Android Studio (version 2023.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)

[√] VS Code (version 1.92.0)
    • VS Code at C:\Users\muhammed\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.94.0

[√] Connected device (4 available)
    • M5 (mobile)       • AR22JU070009 • android-arm64  • Android 8.1.0 (API 27)
    • Windows (desktop) • windows      • windows-x64    • Microsoft Windows [Version 10.0.22631.3880]
    • Chrome (web)      • chrome       • web-javascript • Google Chrome 127.0.6533.89
    • Edge (web)        • edge         • web-javascript • Microsoft Edge 127.0.2651.86

[√] Network resources
    • All expected network resources are available.

Relevant logs output

No response

@Ajmalnk1836 Ajmalnk1836 added the bug Something isn't working label Aug 5, 2024
@ThibaultBee
Copy link
Member

This error is a generic error when device has been disconnected (by the server, connection lost,...), so it is not easy to debug each case.

As pointed in one of your linked issue, reducing the video bitrate could be a solution.
Instead of VideoConfig.defaultBitrate(), use VideoConfig(bitrate: 1000000) // in bps.

@Ajmalnk1836
Copy link
Author

When this issue happened, after that mobile got frozen and crashed. It's due to being unable to disconnect by the server side, i think. But how we can resolve this crashing/frozen issue, its fine stopping the stream Instead of crashing/ frozen
replay would be appreciated, Thank you

@ThibaultBee
Copy link
Member

Could you provide the log trace?

@Ajmalnk1836
Copy link
Author

Sure,

I/        (21871): Format changed : {max-bitrate=2000000, crop-right=719, level=512, mime=video/avc, profile=8, bitrate=2000000, priority=0, intra-refresh-period=0, color-standard=1, csd-1=java.nio.HeapByteBuffer[pos=0 lim=8 cap=8], color-transfer=3, crop-bottom=1279, prepend-sps-pps-to-idr-frames=0, crop-left=0, width=720, bitrate-mode=1, color-range=2, crop-top=0, frame-rate=30, height=1280, csd-0=java.nio.HeapByteBuffer[pos=0 lim=21 cap=21]}
E/rtmpdroid(21871): WriteN, RTMP send error 104 (12 bytes)
E/rtmpdroid(21871): WriteN, RTMP send error 32 (71 bytes)
E/rtmpdroid(21871): WriteN, RTMP send error 9 (42 bytes)
E/RtmpProducer(21871): Error while writing packet to socket
E/RtmpProducer(21871): java.net.SocketException: Connection error
E/RtmpProducer(21871): 	at video.api.rtmpdroid.Rtmp.write(Rtmp.kt:139)
E/RtmpProducer(21871): 	at io.github.thibaultbee.streampack.ext.rtmp.internal.endpoints.RtmpProducer.write(RtmpProducer.kt:94)
E/RtmpProducer(21871): 	at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$muxListener$1.onOutputFrame(BaseStreamer.kt:132)
E/RtmpProducer(21871): 	at io.github.thibaultbee.streampack.internal.muxers.flv.FlvMuxer.encode(FlvMuxer.kt:77)
E/RtmpProducer(21871): 	at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$videoEncoderListener$1.onOutputFrame(BaseStreamer.kt:120)
E/RtmpProducer(21871): 	at io.github.thibaultbee.streampack.internal.encoders.MediaCodecEncoder$encoderCallback$1.onOutputBufferAvailable(MediaCodecEncoder.kt:109)
E/RtmpProducer(21871): 	at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1845)
E/RtmpProducer(21871): 	at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1743
```)


These are logs I'm getting when this issue happened. The problem is we cannot stop the stream, it's getting frozen. It's happening in an example project also.

@ThibaultBee
Copy link
Member

ThibaultBee commented Sep 3, 2024

Is this log from your emulated Pixel 6 (Android 12) from the example?
Does it happen when the stream is starting?

I just tested with a emulated Pixel 6 (Android 12), I don't reproduce this issue.

@Ajmalnk1836
Copy link
Author

The issue occurs intermittently during streaming, without a consistent time frame. It can appear after 10 minutes of streaming or sometimes after 20 minutes. I am currently unable to determine the root cause of the problem.
is It might be related to the media server ? I am using the Antimedia server.

@ThibaultBee
Copy link
Member

Ok,
These info were missing in your description.

In that case, reducing resolution will help you to have longer live.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants