For AI agents: this page in Markdown: https://www.pubnub.com/docs/sdks/asyncio/faq.md. Documentation index: https://www.pubnub.com/llms-full.txt.

FAQ for Python-Asyncio SDK

Can I use the synchronous Python client alongside Asyncio?​

Yes. Use the PubNub client for synchronous workflows and PubNubAsyncio for asynchronous workflows. Initialize the clients separately to avoid event loop conflicts.

Why is a user ID required?​

The User ID identifies the client, which can be an end user, a device, or a server. Set a stable value and keep it for the lifetime of the user or device. Without it, the PubNubAsyncio constructor raises an AssertionError.

How do I enable Transport Layer Security?​

Set pnconfig.ssl = True during configuration. This enables Transport Layer Security (TLS) for all communication with PubNub.

How do I choose a custom HTTP request handler?​

Pass custom_request_handler when you initialize PubNubAsyncio. If you don't, the SDK reads the PUBNUB_ASYNC_REQUEST_HANDLER environment variable. If that variable is unset or invalid, the SDK uses AsyncHttpxRequestHandler.

Why am I not receiving messages after subscribing?​

The SDK doesn't deliver messages published before the subscribe() call. Subscribe before you publish, or retrieve earlier messages with history.

Can I subscribe to multiple channels at once?​

Yes. Use a SubscriptionSet to manage several Subscriptions together. You can also use wildcard subscriptions or channel groups where supported.

How do I filter messages server-side?​

Use pnconfig.filter_expression to set a filter expression. The Stream Controller add-on must be enabled for your keyset.

How do I grant access with Access Manager?​

Use the secret_key only on secure server-side platforms, because the client signs Access Manager messages with it. Never expose this key in client-side code.

How do I troubleshoot connection issues?​

Check status events such as PNConnectionErrorCategory and PNUnexpectedDisconnectCategory. For details, see Status Events.

Was this page useful?

Last updated on