push to facebook: unsupported media type

Gabriel T

Member
Hello
im trying to push to facebook and get the following error as result of the rest query:

https://xxx.com:8888/rest-api/push/startup 415 (Unsupported Media Type)

here is the jquery code im using (where streamID is the streamName):
function pushToFaceBook(streamID) {
$.post('https://xxxcom:8888/rest-api/push/startup', {
"streamName": streamID,
"rtmpUrl": 'rtmps://live-api.facebook.com:443/rtmp/xxx?s_ps=1&a=xxx'
}, function(serverResponse){
})
}
using latest wcs5 build, ubuntu 14.04

any clue ?

beside this, new error coming from time to time:

04:44:49,913 ERROR HLSServerHandler - HLS-HTTP-pool-14-thread-1 HTTP error
java.lang.ArrayIndexOutOfBoundsException: -2
at com.flashphoner.server.B.F.messageReceived(Unknown Source)
at org.jboss.netty.handler.codec.http.HttpChunkAggregator.messageReceived(Unknown Source)
at org.jboss.netty.channel.Channels.fireMessageReceived(Unknown Source)
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(Unknown Source)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(Unknown Source)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(Unknown Source)
at org.jboss.netty.channel.Channels.fireMessageReceived(Unknown Source)
at org.jboss.netty.channel.Channels.fireMessageReceived(Unknown Source)
at org.jboss.netty.channel.socket.nio.NioWorker.read(Unknown Source)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(Unknown Source)
at org.jboss.netty.channel.socket.nio.DeadlockAwareNioWorker.run(Unknown Source)
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)
 

Gabriel T

Member
got it working, was a typo in my js apparently (had to change simple quotes bu double quotes...strange)
so now the rest call is working, but still no publishng: new error message from rest: ERR_SSL_PROTOCOL_ERROR
 

Max

Administrator
Staff member
new error message from rest: ERR_SSL_PROTOCOL_ERROR
Did you import SSL certificates for your domain?
You can also try REST/HTTP request instead of HTTPS:
Code:
http://host:9091/rest-api/...
 

Gabriel T

Member
hello yes ssl is installed and perfectly working. and no i cant make http rest request as i'm making the request from a https url
 

Gabriel T

Member
hello

there might be something wrong in my js function calling the rest api as from chrome rest extension its working fine

can you tell me if you see something wrong in this:

function pushToFaceBook(streamID) {
$.post('https://xxx.com:9091/rest-api/push/startup', {
"streamName": streamID,
"rtmpUrl": "rtmps://live-api.facebook.com:443/rtmp/xxx?s_ps=1&a=xxx"
}, function(serverResponse){
})
}

thank you
 

Max

Administrator
Staff member
Hello
You have to set Content Type "application/json" to get this working.
 

Gabriel T

Member
thank you, i figured this out meanwhile.
still no luck: its working when using rest advanced client in chrome (though have following error in logs:
22:56:36,685 INFO J - pool-34-thread-2 using client version 4CDBBD00
22:56:36,705 WARN A - pool-34-thread-2 un-handled server result for: releaseStream
22:56:36,705 WARN A - pool-34-thread-2 un-handled server result for: FCPublish
22:56:40,772 INFO RtmpPublisher - VideoDistributor-H264-640x480-0-06beb540-4f11-11e8-a6e8-7d68d815c58f
java.lang.Exception
at com.flashphoner.server.J.C.A.B.A(Unknown Source)
at com.flashphoner.media.H.D.playVideo(Unknown Source)
at com.flashphoner.media.I.C.A(Unknown Source)
at com.flashphoner.media.L.B.run(Unknown Source)
at java.lang.Thread.run(Thread.java:748)

and i get a error 500 when using this js:
var formData = new FormData();
formData.append("streamName", streamID);
formData.append("rtmpUrl", "rtmp://live-api.facebook.com:80/rtmp/xxx?s_ps=1&a=xxx");
$.ajax({
type: "POST",
url: "https://xxx:8888/rest-api/push/startup",
crossDomain: true,
data: JSON.stringify(formData),
dataType: 'json',
headers : {
'Content-Type' : 'application/json'
},
success: function(responseData, status, xhr) {
console.log(responseData);
},
error: function(request, status, error) {
console.log(request.responseText);
}
});
 

Max

Administrator
Staff member
Fast way to see what happens is
1. Create an html page available over plain http, not https.
2. Make REST/HTTP request.
Dump HTTP traffic using Wireshark as pcap file.
Please attach this zipped pcap.
Most likely your JSON is malformed.
Try to compare with pcap dump from Advanced REST Console.
To see dumps you need to use HTTP instead of HTTPS, because HTTP is not encrypted.
URL
Code:
http://host:9091/rest-api/push/startup
 

Gabriel T

Member
thanks for reply, that was an error in the js. if it can help others, here is the working js for facebook live (where "_myStreamID" is the stream name):
$.ajax({
type: "POST",
url: "https://xxx:8888/rest-api/push/startup",
crossDomain: true,
data: JSON.stringify({"streamName":_myStreamID,"rtmpUrl":"rtmp://live-api.facebook.com:80/rtmp/xxx?s_ps=1&a=xxx"}),
dataType: "json",
headers : {
"Content-Type" : "application/json"
},
success: function(responseData, status, xhr) {
console.log(responseData);
},
error: function(request, status, error) {
console.log(request.responseText);
}
});
 
Top