Search code examples
iosopentoktokbox

internal error when publishing a stream


I'm using the IOS SDK.

Trying to Publish a stream and getting

Error Domain=OTSessionErrorDomain Code=2000

Code:

session = OTSession(apiKey: kApiKey,
                    sessionId: kSessionId,
                    delegate: self)

var error: OTError?
session.connect(withToken: kToken,
                error: &error)

let settings = OTPublisherSettings()
settings.cameraResolution = .high
settings.cameraFrameRate = .rate30FPS

guard let publisher = OTPublisher(delegate: self, settings: settings) else { return }

session.publish(publisher, error: &error)

I'm getting the error on session.publish

Any idea what can be the problem?

I cant find any list of internal error options.

When i run the example SimpleVideo app with the same credentials everything works good.

Thanks


Solution

  • You might be able to get it working by very little chance because publishing won't be successful until a client has successfully connected to a session. The correct steps should be:

    • Attempt to connect to a session
    • Did connect to a session
    • Attempt to publish to the connected session

    So, you can't call publish right after calling connect method. Instead, you should do publishing in sessionDidConnect:. That is the callback delegate method to ensure that a client has connected a session successfully.