FAQ for C# SDK

Check out the frequently asked questions about the PubNub C# SDK.

Why is a UserId required?

The UserId uniquely identifies the client (end user, device, or server). Set and persist a stable value for the lifetime of the user or device; without it, the client cannot connect.

Can I publish and subscribe with one client?

Yes. The client supports concurrent operations when using the event engine. For explicit control, use separate subscriptions or distinct instances.

How do I enable Transport Layer Security (TLS)?

Set pnConfiguration.Secure = true to enable TLS for all communications with PubNub.

Why am I not receiving messages after subscribing?

Messages published before Subscribe() are not delivered by default. Subscribe first, then publish. Use history to fetch earlier messages when needed.

How do I filter messages server-side?

Set pnConfiguration.FilterExpression. The Stream Controller add-on must be enabled for your keyset.

Which encryption should I use?

Prefer AesCbcCryptor(CipherKey) for 256‑bit AES‑CBC. The legacy cryptor is available for backward compatibility.

How do I configure reconnection behavior?

Use ReconnectionPolicy (NONE, LINEAR, EXPONENTIAL) and optionally set ConnectionMaxRetries. With the event engine, use RetryConfiguration.Linear(...) or RetryConfiguration.Exponential(...).

How do I reduce duplicate messages across regions?

Enable DedupOnSubscribe and tune MaximumMessagesCacheSize.

How do I use a proxy?

Set a Proxy on PNConfiguration with the required host, port, and protocol.

Why are there two subscribe() methods?

The C# SDK offers a modern, entity-based subscribe API and retains a legacy subscribe API for backward compatibility.

Use the modern entity-based approach documented in Subscribe, which creates Subscription or SubscriptionSet instances, relies on a listener model, and can optionally resume from a timetoken via SubscriptionCursor.

The legacy global builder pubnub.Subscribe<string>() is documented in Subscribe (old) and remains for existing applications.

Which subscribe() should I use?

For new development, use the modern Subscribe with Subscription/SubscriptionSet and listeners. Configure presence delivery with SubscriptionOptions and resume with SubscriptionCursor when needed.

For maintaining older apps, continue using Subscribe (old) until you migrate. When migrating, create entities, add event listeners, and optionally resume from a specific timetoken using SubscriptionCursor.

Why does encryption use AES-128 when CryptoModule is configured?

If a call supplies a cipherKey argument (for example, in Encrypt, EncryptFile, Decrypt, or DecryptFile), that argument overrides the configured CryptoModule for that operation and uses legacy Advanced Encryption Standard (AES) with 128-bit keys. Remove the cipherKey argument to use the CryptoModule configuration (AES‑256‑CBC), or configure a separate CryptoModule instance for partial encryption scenarios.

For details, refer to CryptoModule configuration.

Last updated on