Debugging PolyNet™ SDK

This document is for PolyNetSDK version 4 for iOS and tvOS. Its sample code is written in Swift 4.

This section describes the means to verify that the integration of the PolyNet SDK with your application has been performed correctly.

Debugging the application requires a device connected to Xcode and has access to Xcode's console log.

Enabling debug messages

In order to print debug messages to the Xcode console log you need to instruct the PolyNet SDK instance to enable logging. To do so, set the property polyNet.logLevel to .integration .

let polyNet = try? PolyNet(manifestUrl: manifestUrl, channelId: channelId, apiKey: apiKey)
polyNet?.delegate = self
polyNet?.dataSource = self
polyNet?.logLevel = .integration

There are 5 levels of logging available: off, disk, error, info, debug Consult the property doc on Xcode for more info.

Debugging the PolyNet configuration

As explained in the PolyNet SDK configuration section, the call to the PolyNet(manifestUrl: manifestUrl, channelId: channelId, apiKey: apiKey) method will return a PolyNet instance or PolyNetError. If a configuration error occurs due to an incorrect ApiKey search the console log for: Check your API Key. Detail: *{detail}*. If problem persists, contact support at support@system73.com.. If any other error occurs on init search the console log for: The PolyNet SDK has failed to build. Detail: *{detail}*. If problem persists, contact support at support@system73.com., the detail will provide further information about the error.

Debugging the connection to PolyNet

If everything is OK, you should see one of the following messages in the log:

To verify that the nodes are connected, examine the node ID and parent ID in the System73 Dashboard.

If the connection with Backend cannot be opened due to a malformed apiKey search the console log for: Check your API Key. If problem persists, contact support at support@system73.com., you can handle this error in the polyNet:didFailWithError: delegate method with the codes: 600, 601.

If an issue with the Backend Handshake occurs, search the console log for: The PolyNet SDK is not compatible with the backend provided. Backend code: *{handshake_rejected_code}*. This may happen in transitions to newer versions. If problem persists, contact support at support@system73.com., you can handle this error in the polyNet:didFailWithError: delegate method with its code: 701.

If connection to Backend Metrics Endpoint fails search the console log for:Error communicating with backend metrics endpoint. HTTP code: *{http_status_code}*, URL: *{backend_metrics_url}*. If problem persists, contact support at support@system73.com., you can handle this error in the polyNet:didFailWithError: delegate method with its code: 703.

If the content manifest is not reachable by the PolyNet Instance or is not supported, search the log for: Error while getting the local Manifest URL. The original is returned instead. The PolyNet is deactivated., you can handle this error in the polyNet:didFailWithError: delegate method with its code: 700.

Debugging PolyNet content requests

It is vital to verify that the video player is requesting content from the PolyNet, and not directly from the Internet or CDN.

The following messages must be in the console's log to ensure the proper operation of the PolyNet:

Content request URL = ...

If none is present in the log, it means that the player is not using the PolyNet to download content.

Debugging P2P

To verify that peers are able to connect to each other, search the console logs for a message that shows connections and disconnections from peers:

Connected to P2P parent with ID = ...
Disconnected from P2P parent with ID = ...
Connected to P2P child with ID = ...
Disconnected from P2P child with ID = ...

You can see peers come and go by inspecting the parent ID and child ID in the System73 Dashboard.

Debugging reconnections

Backend Connection Related errors will yield: Error communicating with backend. Description: *{custom_description}*. If problem persists, contact support at support@system73.com., you can handle this error in the polyNet:didFailWithError: delegate method with its code: 702.

If the SDK is commanded to connect to a different parent by the Backend, search the console log for one of the following messages:

You can look for the node ID, parent ID in the System73 Dashboard, to verify that the nodes are connected.

Example of the debugging process

The following is an example of a debugging session where 2 devices are connected, and the operation is completed successfully:

  1. You will need an exclusive channel for debugging, which is not used by anyone else. Ensure no other device is connected to the channel. You can verify that in the System73 Dashboard.

  2. Connect the first device to the channel. The device should be playing video. Check that its node ID shows up in the System73 Dashboard, connected to the CDN. Look for the following messages in the console's log:

    Connected successfully to the Backend, with ID = (...). Will fetch from CDN.
    
    Content request URL = ...
    
  3. Connect a second device. The device should be playing video within a few seconds. It should become a child node of the first device. Check that its node ID shows up in the System73 Dashboard, and that it is connected to the first device. Look for the following messages in the console's log:
    In the parent's log:

    Connected to P2P child with ID = (...)
    

    In the child's log:

    Connected successfully to the Backend, with ID = (...). Will fetch from P2P (parent ID = ...).
    
    Connected to P2P parent with ID = (...)
    
    Content request URL = ...