ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.27k stars 629 forks source link

Exception throw stopping rtmp stream in Enterprise Edition #237

Closed mekya closed 6 years ago

mekya commented 6 years ago

When a zombi stream is publish and stopped server throws below exception.

java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:189) at org.red5.server.net.rtmp.RTMPHandler.invokeCall(RTMPHandler.java:214) at org.red5.server.net.rtmp.RTMPHandler.onCommand(RTMPHandler.java:276) at org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived(BaseRTMPHandler.java:116) at org.red5.server.net.rtmp.ReceivedMessageTask.call(ReceivedMessageTask.java:72) at org.red5.server.net.rtmp.ReceivedMessageTask.call(ReceivedMessageTask.java:38) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NullPointerException: null at org.red5.server.stream.ClientBroadcastStream.close(ClientBroadcastStream.java:284) at org.red5.server.stream.StreamService.deleteStream(StreamService.java:238) ... 16 common frames omitted

maydin commented 6 years ago

http://localhost:5080/WebRTCAppEE/player.html bir hata buldum:

ffmpeg ile yapilan yayini izlerken control-c ile kapattim ffmpeg'i. yayini tekrar baslattim. webplayer start'a basinca oynatmadi. sayfayi refresh yapmak gerekiyor.

maydin commented 6 years ago

ffmpeg ile LiveApp ve WebRTCApp'e yayin yapip control+c ile ciktik defalarca ama hatayi tekrar edemedim. Bir ara gordum o hatayi ama o log OBS ile tutorial yazarkenyazilmis olabilir. OBS ile de denedim ama olmadi. /* {@inheritDoc} / public void deleteStream(IStreamCapableConnection conn, Number streamId) { IClientStream stream = conn.getStreamById(streamId); if (stream != null) { if (stream instanceof IClientBroadcastStream) { IClientBroadcastStream bs = (IClientBroadcastStream) stream; IBroadcastScope bsScope = getBroadcastScope(conn.getScope(), bs.getPublishedName()); if (bsScope != null && conn instanceof BaseConnection) { ((BaseConnection) conn).unregisterBasicScope(bsScope); } } stream.close(); } conn.unreserveStreamId(streamId); }

Yukarida stream.close();'da hata aliniyor. close icinde de

IClusterNotifier clusterNotifierTmp = getClusterNotifier(); if (clusterNotifierTmp != null) { IScope scope = Red5.getConnectionLocal().getScope(); clusterNotifierTmp.sendStreamNotification(publishedName, scope.getName(), StreamEvent.STREAM_UNPUBLISHED); }

su satirda clusterNotifierTmp.sendStreamNotification aliniyor. null check yapilmasina ragmen null check sonrasi null olmus olabilir. close veya sendStreamNotification dan once de null check yapilabilir.

Soyle bir referans da var: https://stackoverflow.com/questions/47805488/copy-reference-to-avoid-npe-if-close-happens-after-null-check

mekya commented 6 years ago

Sanki hata close içinde değil tam o satırda alınıyor.

Yani stream değişkeni null gibi geldi bana.

Caused by: java.lang.NullPointerException: null
at org.red5.server.stream.ClientBroadcastStream.close(ClientBroadcastStream.java:284)
at org.red5.server.stream.StreamService.deleteStream(StreamService.java:238) 
maydin commented 6 years ago

Zaten sonrasinda clusterNotifierTmp.sendStreamNotification satirinda diye belirtmisim hocam.