mediasoup-ios-client: Error on MediasoupDevice.createSendTransport

I’m trying to create sendTransport and got error.

*** Terminating app due to uncaught exception ‘RuntimeException’, reason: ‘[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected ‘[’, ‘{’, or a literal’

I think that problem could be somewhere in iceParameters, iceCandidates or dtlsParameters… I’m using Codable approach and short extension to encode this parameters before using.

var jsonEncoded: String {
        guard let jsonData = try? JSONEncoder().encode(self) else {
            fatalError("Encoding error")
        }
        return String(data: jsonData, encoding: .utf8)!
  }

Nothing special. And this encoding worked with MediasoupDevice.load method… Can someone help me resolve this issue?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

Latest for both.
Can’t tell you the numbers since I can’t access my project right now, but I ran pod update on it today and it was still working for the create transport call.

edit:

  • Socket.IO-Client-Swift (15.2.0):
  • SwiftyJSON (5.0.0)

Hi @NullIsOne
I’m also using Socket.io for signaling and got the createSendTransport working as in the sample below.
Maybe you can try it like this (without using Codable) once and see if it works.
Maybe your socket.io server side is not passing valid json in the first place?

socket.emitWithAck(/*...*/).timingOut(/*...*/) { [weak self] transportData in
            guard let self = self else { return }
            let id: String = transportData["id"].stringValue
            let iceParams = transportData["iceParameters"].description
            let iceCandidates = transportData["iceCandidates"].description
            let dtlsParams = transportData["dtlsParameters"].description
            self.sendTransport = self.device.createSendTransport(self,
                                                                 id: id,
                                                                 iceParameters: iceParams,
                                                                 iceCandidates: iceCandidates,
                                                                 dtlsParameters: dtlsParams)
// other stuff
        }