Status Events for PubNub Windows C SDK
C-core status codes and user actions
These are the symbols from the enum pubnub_res
which is used throughout the C-core API to convey the information about the outcome of a Pubnub transaction. They are used in both C and C++, on all platforms.
General Errors Handling
If your Pubnub transaction fails, you might want to retry. But, sometimes that may not be such a good idea. To that end, there is a function pubnub_should_retry()
and its wrapper, member function should_retry()
in C++. See their documentation about their usage.
To get a string describing a C-core
status code, call pubnub_res_2_string()
.
Also, increasing the C-core logging to maximum will output a lot of data useful in diagnosing the cause of errors/failures.
The List
Symbol/code | Description | User action |
---|---|---|
PNR_OK | Transaction success. | Proceed with business as usual. |
PNR_ADDR_RESOLUTION_FAILED | Pubnub host name resolution failed. We failed to get an IP address from the Pubnub host name (origin ). Most of the time, this comes down to a DNS error. | Check your network, focusing on DNS issues. |
PNR_CONNECT_FAILED | Connecting to Pubnub server failed. Most often, this means a network outage, but could be many things. If using SSL/TLS, it could be some of its errors. | Check your network including any firewall/proxy. If using SSL/TLS, check the errors reported, try using fallback. |
PNR_CONNECTION_TIMEOUT | A time-out happened in the network. Mostly, this is because a network outage happened while being connected to the Pubnub server, but could be other things. | Treat this similarly to PNR_CONNECT_FAILED , but focus more on hardware / low level IP issues. |
PNR_TIMEOUT | Time-out before the request has completed. This is reported for a time-out detected by Pubnub client itself, not some reported by others (i.e. the TCP/IP stack). | Increase the transaction timeout you used. If that doesn't help, treat it like PNR_CONNECTION_TIMEOUT . |
PNR_ABORTED | Connection to Pubnub aborted (in most cases, a TCP reset was received). | This is very unlikely, unless you're using a proxy - in which case, check the proxy. If not using proxy, please report this to PubNub. |
PNR_IO_ERROR | Communication error (network or HTTP response format) | If you're using a proxy, please check the proxy. Otherwise, this indicates some SW error, possibly problem in C-core itself. Please report this to PubNub. |
PNR_HTTP_ERROR | An error reported in HTTP status code, not detected by some other means. | This is a fallback to the cases that C-core hasn't covered yet. Call pubnub_last_http_code() to get the error code. Also, read the actual response to understand what was the problem. |
PNR_FORMAT_ERROR | Unexpected input in received JSON. | If using a proxy, please check the proxy. Otherwise, this is most likely an error in C-core parsing, so please report this to PubNub. |
PNR_CANCELLED | User cancelled a transaction. | If you haven't cancelled a transaction, please report this to Pubnub. |
PNR_STARTED | Transaction started - this is not an error code, but information/status code. | Await the final outcome. |
PNR_IN_PROGRESS | Transaction (already) ongoing. Can't start a new transaction while the old one is in progress. | Await the final outcome of the current transaction or start it in another context. |
PNR_RX_BUFF_NOT_EMPTY | Receive buffer (from previous transaction) not read, new subscription not allowed. | Read the whole receive buffer. |
PNR_TX_BUFF_TOO_SMALL | The transmit buffer is too small. | Increase #PUBNUB_BUF_MAXLEN or divide your message to multiple segments. |
PNR_INVALID_CHANNEL | Channel specification / name is invalid. | Use a valid channel name/specification. |
PNR_PUBLISH_FAILED | Publish transaction failed - error returned from Pubnub. | To see the reason describing the failure, call pubnub_last_publish_result() . |
PNR_CHANNEL_REGISTRY_ERROR | A transaction related to channel registry failed - error returned from Pubnub. | To see the reason describing the failure, get the value for key message from the response (which is a JSON object) and value for key status for the numeric code of the error. |
PNR_REPLY_TOO_BIG | Reply is too big to fit in our reply buffer. This same error is reported if the reply buffer is statically or dynamically allocated. | If using statically allocated buffer, increase the buffer size. Otherwise, this indicates you need more RAM. |
PNR_INTERNAL_ERROR | An internal error in processing. | Please report to Pubnub. |
PNR_CRYPTO_NOT_SUPPORTED | Encryption (and decryption) not supported. | Switch to a platform that supports encryption/decryption (like OpenSSL) or don't use it. |