RTMP Re-publish from external source

chako

New Member
Hello,
I have created new app using console
app name : XXX,
app name : live
added rest hooks as described in post for both of the apps https://docs.flashphoner.com/display/WCS5EN/Using+REST+hook+to+authorize+user+by+domain
i want to authorise user by domain
i have added rtmp_appkey_source=app to my flashphoner.properties
now i have started 4 streams
rtmp://host:1935/live/stream_name
rtmp://host:1935/XXX/stream_name2
rtmp://host:1935/XXX/stream_name3
rtmp://host:1935/live?appKey=XXX/stream_name2

now issues i'm facing
i'm getting 404 on HOST/8444/rest-api/stream/find_all
{
"exception": "com.flashphoner.rest.server.exception.NotFoundException",
"path": "/rest-api/stream/find_all",
"error": "Not Found",
"message": "NOT FOUND",
"timestamp": 1550122681203,
"status": 404
}
i'm not able to play any stream it always shows failed
i looked in to server logs that shows
INFO Peer - ForkJoinPool.commonPool-worker-1 Flash client connected false
ServerHandler - ForkJoinPool.commonPool-worker-1 Connection failed, id 1
ServerHandler - RTMP-pool-14-thread-1 IO error on socket [id: 0x4e732d97
ServerHandler - RTMP-pool-14-thread-1 channel closed:
RTMP-Session - RTMP-pool-14-thread-1 kill session 1316171159
i have mailed server,client logs and conf files to the support@flashphoner.com
 

Max

Administrator
Staff member
Hello.
If you publish RTMP stream using your server application, you should set corresponding handlers for direct calls and callbacks. Default handlers (WCS4Handler and WCS4CallbackHandler) works with WebRTC streams, not RTMP.
For example:
Code:
update app -m com.flashphoner.server.client.handler.wcs4.FlashStreamingHandler -c com.flashphoner.server.client.handler.wcs4.FlashStreamingCallbackHandler live
You should set it for both your applications.
 

chako

New Member
no i'm not planning publish with my server application
my requirement is i have 4-5 RTMP streams which i'll broadcast using WCS this works well in defaulApp but i need to authenticate user by domain and some custom token before connecting and playing stream so i have implemented web hooks to newly created apps and implemented in it i can't get what i'm doing wrong
can you have a look at my WCS and guide me the right path
 
Last edited:

Max

Administrator
Staff member
You probably add your applications like this:
Code:
add app Live live "http://bro4bet.live/rest"
add app-rest-method -a live
That was right.
But if you broadcast RTMP streams to WCS server, you should aslo do this
Code:
update app -m com.flashphoner.server.client.handler.wcs4.FlashStreamingHandler -c com.flashphoner.server.client.handler.wcs4.FlashStreamingCallbackHandler live
and the same for your second application.
That's all. RTMP streams will broadcast to your WCS successfully, we've tested it. Your backend receives REST hooks and replies to WCS as we see in logs.
 

chako

New Member
You probably add your applications like this:
Code:
add app Live live "http://bro4bet.live/rest"
add app-rest-method -a live
That was right.
But if you broadcast RTMP streams to WCS server, you should aslo do this
Code:
update app -m com.flashphoner.server.client.handler.wcs4.FlashStreamingHandler -c com.flashphoner.server.client.handler.wcs4.FlashStreamingCallbackHandler live
and the same for your second application.
That's all. RTMP streams will broadcast to your WCS successfully, we've tested it. Your backend receives REST hooks and replies to WCS as we see in logs.
I did what you said i guess that worked but when i open player.html now that doesn't show me failed but loader is spinning but i can't see stream, can you please check the logs i have send on support.
I m publishing total 4 streams to different apps but i can't able to see two streams which is on live app and tv_app app, i checked in console using show streams, and rest-api call but on both end i m not able to locate other two streams
 
Last edited:

Max

Administrator
Staff member
Hello.
We have published RTMP stream to your server
Code:
ffmpeg --re -y -rtbufsize 1k -i file.mp4 -preset ultrafast -vcodec h264 -acodec aac -ar 48000 -strict -2 -f flv -b:v 1M rtmp://your_host:1935/tv_app/flashphoner_test
and played with Embed Player
Code:
https://demo.flashphoner.com:8888/embed_player?urlServer=wss://your_host:8443&streamName=flashphoner_test&mediaProviders=WebRTC
The stream is played successfully, both for live app and tv_app app.
So, check your RTMP stream source. How do you broadcast RTMP to server?
Also, we see in your logs many failed attempts to play RTSP streams. In this case, either RTSP source is not available (Can not connect to rtsp_source:554) or RTSP source sends wrong SDP without track information:
09:25:01,063 WARN RtspAgent - pool-45-thread-1 Can't extract tracks from response sdp: v=0
o=- 18467 41 IN IP4 0.0.0.0
c=IN IP4 0.0.0.0
a=control:*
a=range:npt=0-
t=0 0
So, check your RTSP source.
 

chako

New Member
Hello i checked that stream in embedded player all the stream works perfectly but embedded player use defaultApp so that stream plays without using my rest hooks and when i try to play using appKey as live or tv_app from my hosted player.html stream doesn't play it just loading can you have a look at player.html
and that rtsp thing actually my all rtsp stream is turned off so i'm aware of that error.
what i did is i pass appKey: 'KEY_NAME'
like this
Code:
Flashphoner.createSession({urlServer: url,appKey: 'tv_app'})
 
Last edited:

Max

Administrator
Staff member
You use tv_app for RTMP broadcasting. So, to play your stream as WebRTC you should add another application, for example
Code:
add app Play_app play_app "http://your_host/rest"
add app-rest-method -a play_app
and pass its key
Code:
Flashphoner.createSession({urlServer: url,appKey: 'play_app'})
Or, you can use:
- live app for RTMP broadcasting only
- tv_app for WebRTC playback only.
In this case, you should set handlers for tv_app as
Code:
update app -m com.flashphoner.server.client.handler.wcs4.WCS4Handler -c com.flashphoner.server.client.handler.wcs4.WCS4CallbackHandler tv_app
and playback should work after that. But you should not publish RTMP as rtmp://your_host:1935/tv_app/stream1
 
Top