Discussions
Unable to create WebRTC connection to the livestream API: Error: "missing or invalid session_id"
Hey d-id,
am a big fan of your technology and would really like to use your live stream api for a great project but I can only connect to your server when I use the demo app of your GitHub repository. But I need to connect from within an iOS app to your livestream api. So I went back to your step-by-step tutorial on your developer hub: https://docs.d-id.com/reference/startconnection.
In Step 1: Create a New Session
everything works fine and I get the following offer from your server back:
{
"id": "strm_gXSWSnLkZnAQvBhS5FnXb",
"offer": {
"type": "offer",
"sdp": "v=0\r\no=- 1700046455641053 1 IN IP4 35.91.90.254\r\ns=Mountpoint 6679196535828918\r\nt=0 0\r\na=group:BUNDLE a v d\r\na=ice-options:trickle\r\na=fingerprint:sha-256 9A:1A:2E:CF:9F:4F:D4:38:17:00:66:F1:A0:74:19:5E:01:A7:C9:AC:6C:DC:6E:F1:39:20:A7:D1:06:54:55:C1\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS *\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 35.91.90.254\r\na=sendonly\r\na=mid:a\r\na=rtcp-mux\r\na=ice-ufrag:ttpG\r\na=ice-pwd:8i1s0yijSW91whNZNzmcxH\r\na=ice-options:trickle\r\na=setup:actpass\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=msid:janus janusa\r\na=ssrc:1489269045 cname:janus\r\na=candidate:1 1 udp 2015363327 35.91.90.254 34935 typ host\r\na=candidate:2 1 udp 1679819007 35.91.90.254 34935 typ srflx raddr 172.18.0.4 rport 34935\r\na=end-of-candidates\r\nm=video 9 UDP/TLS/RTP/SAVPF 100 101\r\nc=IN IP4 35.91.90.254\r\na=sendonly\r\na=mid:v\r\na=rtcp-mux\r\na=ice-ufrag:ttpG\r\na=ice-pwd:8i1s0yijSW91whNZNzmcxH\r\na=ice-options:trickle\r\na=setup:actpass\r\na=rtpmap:100 VP8/90000\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=ssrc-group:FID 873572135 91224092\r\na=msid:janus janusv\r\na=ssrc:873572135 cname:janus\r\na=ssrc:91224092 cname:janus\r\na=candidate:1 1 udp 2015363327 35.91.90.254 34935 typ host\r\na=candidate:2 1 udp 1679819007 35.91.90.254 34935 typ srflx raddr 172.18.0.4 rport 34935\r\na=end-of-candidates\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 35.91.90.254\r\na=sendrecv\r\na=mid:d\r\na=sctp-port:5000\r\na=ice-ufrag:ttpG\r\na=ice-pwd:8i1s0yijSW91whNZNzmcxH\r\na=ice-options:trickle\r\na=setup:actpass\r\na=candidate:1 1 udp 2015363327 35.91.90.254 34935 typ host\r\na=candidate:2 1 udp 1679819007 35.91.90.254 34935 typ srflx raddr 172.18.0.4 rport 34935\r\na=end-of-candidates\r\n"
},
"ice_servers": [
{
"urls": "stun:stun.kinesisvideo.us-west-2.amazonaws.com:443"
},
{
"urls": [
"turn:52-11-72-55.t-853e5b95.kinesisvideo.us-west-2.amazonaws.com:443?transport=udp",
"turns:52-11-72-55.t-853e5b95.kinesisvideo.us-west-2.amazonaws.com:443?transport=udp",
"turns:52-11-72-55.t-853e5b95.kinesisvideo.us-west-2.amazonaws.com:443?transport=tcp"
],
"username": "1700046755:djE6YXJuOmF3czpraW5lc2lzdmlkZW86dXMtd2VzdC0yOjg5OTAxNjUwOTUyMDpjaGFubmVsL3RhbGtzLXN0cmVhbWVyLXByb2QtMjYvMTY3NzE2OTkyNTU4OA==",
"credential": "DnpMsP+RKxUGffV9XydN0JnDkUXW8jh3wLZnHuTf8AA="
}
],
"session_id": "AWSALB=1xPksIrb5nhWRuo6alIlPimIfz1m6ii13d0u64E1iwCV86RbeouivP0Kt+WZ56We5salA/yJqQseNj/i31Ij1Jj2FE16PGxFzo5zLtGS3ZEI6um+xanBoCYsoHVG; Expires=Wed, 22 Nov 2023 11:07:35 GMT; Path=/; AWSALBCORS=1xPksIrb5nhWRuo6alIlPimIfz1m6ii13d0u64E1iwCV86RbeouivP0Kt+WZ56We5salA/yJqQseNj/i31Ij1Jj2FE16PGxFzo5zLtGS3ZEI6um+xanBoCYsoHVG; Expires=Wed, 22 Nov 2023 11:07:35 GMT; Path=/; SameSite=None; Secure"
}
I then go to
STEP 2 START A STREAM
and type in the id string that I received, an sdp answer that I created with an IOS app and what I believe to be the SESSION ID that I received in step 1:
AWSALB=1xPksIrb5nhWRuo6alIlPimIfz1m6ii13d0u64E1iwCV86RbeouivP0Kt+WZ56We5salA/yJqQseNj/i31Ij1Jj2FE16PGxFzo5zLtGS3ZEI6um+xanBoCYsoHVG; Expires=Wed, 22 Nov 2023 11:07:35 GMT; Path=/; AWSALBCORS=1xPksIrb5nhWRuo6alIlPimIfz1m6ii13d0u64E1iwCV86RbeouivP0Kt+WZ56We5salA/yJqQseNj/i31Ij1Jj2FE16PGxFzo5zLtGS3ZEI6um+xanBoCYsoHVG; Expires=Wed, 22 Nov 2023 11:07:35 GMT; Path=/; SameSite=None; Secure
But the response from your server is:
{
"kind": "SessionError",
"description": "missing or invalid session_id"
}
Enclosed is the complete code that is generated for Step 2 in your tutorial code box.
Do you have any idea what I am doing wrong? Your help would be very much appreciated!!
Many thanks and kind regards,
Robin
import Foundation
let headers = [
"accept": "application/json",
"content-type": "application/json",
"authorization": "Basic -------------------------"
]
let parameters = [
"answer": [
"type": "answer",
"sdp": "v=0 o=- 252916836452524058 2 IN IP4 127.0.0.1 s=- t=0 0 a=group:BUNDLE a d a=extmap-allow-mixed a=msid-semantic: WMS m=audio 9 UDP/TLS/RTP/SAVPF 111 c=IN IP4 0.0.0.0 a=rtcp:9 IN IP4 0.0.0.0 a=ice-ufrag:Nxn+ a=ice-pwd:zhi9gW9HgX4AnOK02KzfrUDY a=ice-options:trickle renomination a=fingerprint:sha-256 A2:1D:B7:9C:1E:F5:9E:72:02:A0:7D:27:10:20:9C:7E:1F:39:D4:FF:B8:55:61:A2:E9:59:9A:E8:19:02:03:3D a=setup:active a=mid:a a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid a=recvonly a=rtcp-mux a=rtpmap:111 opus/48000/2 a=rtcp-fb:111 transport-cc a=fmtp:111 minptime=10;useinbandfec=1 m=video 0 UDP/TLS/RTP/SAVPF 0 c=IN IP4 0.0.0.0 a=rtcp:9 IN IP4 0.0.0.0 a=ice-ufrag:xVrZ a=ice-pwd:5mEFE9pTEc8E8t7pKK6bVgNu a=ice-options:trickle renomination a=fingerprint:sha-256 A2:1D:B7:9C:1E:F5:9E:72:02:A0:7D:27:10:20:9C:7E:1F:39:D4:FF:B8:55:61:A2:E9:59:9A:E8:19:02:03:3D a=setup:active a=mid:v a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid a=recvonly a=rtcp-mux m=application 9 UDP/DTLS/SCTP webrtc-datachannel c=IN IP4 0.0.0.0 a=ice-ufrag:Nxn+ a=ice-pwd:zhi9gW9HgX4AnOK02KzfrUDY a=ice-options:trickle renomination a=fingerprint:sha-256 A2:1D:B7:9C:1E:F5:9E:72:02:A0:7D:27:10:20:9C:7E:1F:39:D4:FF:B8:55:61:A2:E9:59:9A:E8:19:02:03:3D a=setup:active a=mid:d a=sctp-port:5000"
],
"session_id": "AWSALB=1xPksIrb5nhWRuo6alIlPimIfz1m6ii13d0u64E1iwCV86RbeouivP0Kt+WZ56We5salA/yJqQseNj/i31Ij1Jj2FE16PGxFzo5zLtGS3ZEI6um+xanBoCYsoHVG; Expires=Wed, 22 Nov 2023 11:07:35 GMT; Path=/; AWSALBCORS=1xPksIrb5nhWRuo6alIlPimIfz1m6ii13d0u64E1iwCV86RbeouivP0Kt+WZ56We5salA/yJqQseNj/i31Ij1Jj2FE16PGxFzo5zLtGS3ZEI6um+xanBoCYsoHVG; Expires=Wed, 22 Nov 2023 11:07:35 GMT; Path=/; SameSite=None; Secure"
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.d-id.com/talks/streams/strm_gXSWSnLkZnAQvBhS5FnXb/sdp")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()