On this page

FAQ for Dart SDK

Check out the frequently asked questions about the PubNub Dart 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. Use a Subscription for real-time updates and publish from the same PubNub instance.

How do I enable Transport Layer Security (TLS)?

Set ssl: true on the NetworkingModule 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.

Why does publish fail with RequestOtherException on macOS?

RequestOtherException usually means the HTTP request failed before PubNub returned a response (network or platform restriction), not an invalid channel name.

On macOS, Flutter desktop apps often run inside App Sandbox. If outbound network is blocked, publish and subscribe fail. Add the client network entitlement to macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements:

<key>com.apple.security.network.client</key>
<true/>

Rebuild the app after changing entitlements. For full setup steps, see Getting Started — Platform permissions.

How do I filter messages server-side?

Set filterExpression on the keyset. The Stream Controller add-on must be enabled for your keyset.

Which encryption should I use?

Prefer 256‑bit AES‑CBC via CryptoModule. The legacy 128‑bit option is available for backward compatibility.

How do I configure reconnection behavior?

Set retryPolicy on the NetworkingModule (exponential or linear). Non‑subscribe requests do not retry.

How do I use a proxy?

Provide a custom NetworkingModule that routes traffic through your proxy and origin.

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

If a call supplies a cipherKey argument (for example, in file encrypt/decrypt helpers), 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.