SelectUnity SDK Troubleshooting Guide

These docs are for version 3.7.10 of the Unity SDK. To check out the docs for the latest version Click Here.
 

PubNub 4.x for Unity is our latest and greatest! Please click here for our PubNub 4.x for Unity docs and SDK.

PubNub 3.x for Unity will encounter End Of Life (EOL) Mar 12, 2019. All users currently on 3.x should begin migrating to 4.x. The 3.x SDK will continue to work. We will no longer support it and if you run into an issue, we will request that you upgrade to the latest version before solving the issue.

If you have questions about the PubNub for Unity SDK, please contact us at support@pubnub.com.

PubnubErrorLevel to PubnubErrorFilter.Level.Info

And

PubnubLogLevel to LoggingMethod.Level.Verbose

In addition to setting the variables you also need to add a define symbol: ENABLE_PUBNUB_LOGGING for each of the platform you want to enable logging. This setting is available in the Unity Editor: File-> Build Settings -> Player Settings -> Other Settings -> Configuration -> Scripting define symbols. After you type ENABLE_PUBNUB_LOGGING in it do remember to press return with the focus still in the text box or your setting will not be saved.

CodeTypeDescription
103
Warning
Verify origin host name and internet connectivity.
104
Critical
Verify your cipher key.
106
Warning
Check network/internet connection.
108
Warning
Check network/internet connection.
109
Warning
No network/internet connection. Please check network/internet connection.
110
Informational
Network/internet connection is back. Active subscriber/presence channels will be restored.
111
Informational
Duplicate channel subscription is not allowed. Internally Pubnub API removes the duplicates before processing.
112
Informational
Channel Already Subscribed/Presence Subscribed. Duplicate channel subscription not allowed.
113
Informational
Channel Already Presence-Subscribed. Duplicate channel presence-subscription not allowed.
114
Warning
Please verify your cipher key.
115
Warning
Protocol Error. Please contact PubNub with error details.
116
Warning
ServerProtocolViolation. Please contact PubNub with error details.
117
Informational
Input contains invalid channel name.
118
Informational
Channel not subscribed yet.
119
Informational
Channel not subscribed for presence yet.
120
Informational
Incomplete unsubscribe. Try again for unsubscribe.
121
Informational
Incomplete presence-unsubscribe. Try again for presence-unsubscribe.
122
Informational
Network/Internet connection not available. C# client retrying again to verify connection. No action is needed from your side.
123
Informational
During non-availability of network/internet, max retries for connection were attempted. So unsubscribed the channel.
124
Informational
During non-availability of network/internet, max retries for connection were attempted. So presence-unsubscribed the channel.
125
Informational
Publish operation timeout occurred.
126
Informational
HereNow operation timeout occurred.
127
Informational
Detailed History operation timeout occurred.
128
Informational
Time operation timeout occurred.
4000
Warning
Message too large. Your message was not sent. Try to send this again smaller sized.
4001
Warning
Bad Request. Please check the entered inputs or web request URL.
4002
Warning
Invalid Key. Please verify the publish key.
4010
Critical
Please provide correct subscribe key. This corresponds to a 401 on the server due to a bad sub key.
4020
Warning
PAM is not enabled. Please contact PubNub support.
4030
Warning
Not authorized. Check the permimissions on the channel. Also verify authentication key, to check access.
4031
Warning
Incorrect public key or secret key.
4040
Warning
Length of the URL is too long. Reduce the length by reducing subscription/presence channels or grant/revoke/audit channels/auth key list.
5000
Critical
Internal Server Error. Unexpected error occured at PubNub Server. Please try again. If same problem persists, please contact PubNub support.
5020
Critical
Bad Gateway. Unexpected error occured at PubNub Server. Please try again. If same problem persists, please contact PubNub support.
5040
Critical
Gateway Timeout. No response from server due to PubNub server timeout. Please try again. If same problem persists, please contact PubNub support.
0
Warning
Undocumented error. Please contact PubNub support with full error object details for further investigation.
static void DisplayErrorMessage(PubnubClientError pubnubError)
{
  UnityEngine.Debug.Log(pubnubError.StatusCode)

  //Based on the severity of the error, we can filter out errors for handling or logging.
  switch (pubnubError.Severity)
  {
    case PubnubErrorSeverity.Critical:
      //This type of error needs to be handled.
      break;
    case PubnubErrorSeverity.Warn:
      //This type of error needs to be handled
      break;
    case PubnubErrorSeverity.Info:
      //This type of error can be ignored
      break;
    default:
      break;
  }

  UnityEngine.Debug.Log(pubnubError.StatusCode); //Unique ID of the error

  UnityEngine.Debug.Log(pubnubError.Message); //Message received from client or server. From client, it could be from .NET exception.

  if (pubnubError.DetailedDotNetException != null)
  {
    UnityEngine.Debug.Log(pubnubError.IsDotNetException); // Boolean flag to check .NET exception
    UnityEngine.Debug.Log(pubnubError.DetailedDotNetException.ToString()); // Full Details of .NET exception
  }

  UnityEngine.Debug.Log(pubnubError.MessageSource); // Did this originate from Server or Client-side logic

  if (pubnubError.PubnubWebRequest != null)
  {
    //Captured Web Request details
    UnityEngine.Debug.Log(pubnubError.PubnubWebRequest.RequestUri.ToString()); 
    UnityEngine.Debug.Log(pubnubError.PubnubWebRequest.Headers.ToString()); 
  }

  if (pubnubError.PubnubWebResponse != null)
  {
    //Captured Web Response details
    UnityEngine.Debug.Log(pubnubError.PubnubWebResponse.Headers.ToString());
  }

  UnityEngine.Debug.Log(pubnubError.Description); // Useful for logging and troubleshooting and support
  UnityEngine.Debug.Log(pubnubError.Channel); //Channel name(s) at the time of error
  UnityEngine.Debug.Log(pubnubError.ErrorDateTimeGMT); //GMT time of error

}
private static void DisplayReturnMessage(string publishResult)
{
  if (!string.IsNullOrEmpty(publishResult) && !string.IsNullOrEmpty(publishResult.Trim()))
  {
    object[] deserializedMessage = pubnub.JsonPluggableLibrary.DeserializeToObject(publishResult) as object[];
    if (deserializedMessage is object[] && deserializedMessage.Length == 3)
    {
      long statusCode = Int64.Parse(deserializedMessage[0].ToString());
      string statusMessage = (string)deserializedMessage[1];
      string channelName = (string)deserializedMessage[2];

      if (statusCode == 1 && statusMessage.ToLower() == "sent")
      {
        UnityEngine.Debug.Log("Cool. Message Published");
      }
      else
      {
        UnityEngine.Debug.Log("Oops. Some problem."); 
      }
    }
  }
}
private static void DisplaySubscribeConnectStatusMessage(string result)
{
  if (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(result.Trim()))
  {
    object[] deserializedResult = pubnub.JsonPluggableLibrary.DeserializeToObject(result) as object[];
    if (deserializedResult is object[])
    {
      int statusCode = Int32.Parse(deserializedResult[0].ToString());
      string statusMessage = (string)deserializedResult[1];
      string channel = (string)deserializedResult[2];
      if (statusCode == 1 && statusMessage.ToLower() == "connected")
      {
        UnityEngine.Debug.Log("Now we are good to receive published messages");
      }
    }
  }
}