api connection issue
i am trying to create a bot and when i do want to use the library i have the same error. i have tried different "ORIGIN" links as per issues found here but none works.
DEBUG: CONFIG.USER_ID value: 4xxxxxxx(modified)
DEBUG_POAPI_CLIENT: SSID received by AsyncPocketOptionClient: 'dxxxxxxxxxxxxxxxxxxxxxxxxxxxx'(modified)
2025-07-15 20:51:38.211 | INFO | pocketoptionapi_async.client:init:133 - Initialized PocketOption client (demo=True, uid=84402008, persistent=False) with enhanced monitoring
2025-07-15 20:51:38.211 | INFO | pocketoptionapi_async.client:connect:165 - Connecting to PocketOption...
2025-07-15 20:51:38.211 | INFO | pocketoptionapi_async.client:_start_regular_connection:190 - Starting regular connection...
2025-07-15 20:51:38.211 | INFO | pocketoptionapi_async.client:_start_regular_connection:201 - Demo mode: Using demo regions: ['DEMO', 'DEMO_2']
2025-07-15 20:51:38.211 | INFO | pocketoptionapi_async.client:_start_regular_connection:222 - Trying region: DEMO with URL: wss://demo-api-eu.po.market/socket.io/?EIO=4&transport=websocket
2025-07-15 20:51:38.211 | INFO | pocketoptionapi_async.websocket_client:connect:162 - Attempting to connect to wss://demo-api-eu.po.market/socket.io/?EIO=4&transport=websocket
2025-07-15 20:51:38.596 | INFO | pocketoptionapi_async.websocket_client:connect:192 - Connected to DEMO-EU region successfully
2025-07-15 20:51:38.681 | INFO | pocketoptionapi_async.client:_start_regular_connection:229 - Connected to region: DEMO
2025-07-15 20:51:38.982 | WARNING | pocketoptionapi_async.websocket_client:receive_messages:395 - WebSocket connection closed
2025-07-15 20:51:38.982 | WARNING | pocketoptionapi_async.client:_on_disconnected:1217 - Disconnected from PocketOption
2025-07-15 20:51:38.982 | INFO | pocketoptionapi_async.websocket_client:_handle_disconnect:736 - Attempting reconnection 1/5
2025-07-15 20:51:48.769 | WARNING | pocketoptionapi_async.client:_start_regular_connection:245 - Failed to connect to region DEMO: Authentication timeout
2025-07-15 20:51:48.769 | INFO | pocketoptionapi_async.client:_start_regular_connection:222 - Trying region: DEMO_2 with URL: wss://try-demo-eu.po.market/socket.io/?EIO=4&transport=websocket
2025-07-15 20:51:48.769 | INFO | pocketoptionapi_async.websocket_client:connect:162 - Attempting to connect to wss://try-demo-eu.po.market/socket.io/?EIO=4&transport=websocket
2025-07-15 20:51:49.070 | INFO | pocketoptionapi_async.websocket_client:connect:192 - Connected to DEMO region successfully
2025-07-15 20:51:49.141 | INFO | pocketoptionapi_async.client:_start_regular_connection:229 - Connected to region: DEMO_2
2025-07-15 20:51:49.285 | WARNING | pocketoptionapi_async.websocket_client:receive_messages:395 - WebSocket connection closed
2025-07-15 20:51:49.285 | WARNING | pocketoptionapi_async.client:_on_disconnected:1217 - Disconnected from PocketOption
2025-07-15 20:51:49.285 | INFO | pocketoptionapi_async.websocket_client:_handle_disconnect:736 - Attempting reconnection 1/5
2025-07-15 20:51:59.206 | WARNING | pocketoptionapi_async.client:_start_regular_connection:245 - Failed to connect to region DEMO_2: Authentication timeout
2025-07-15 20:51:59.206 | ERROR | pocket_trader.api.po_api:connect:21 - Failed to connect to Pocket Option API.
2025-07-15 20:51:59.206 | CRITICAL | main:main:23 - Bot cannot start without API connection. Exiting.
probably your SSID is wrong, your client initialisation should look like this:
from pocketoptionapi_async import AsyncPocketOptionClient
async def main():
SSID = input("Enter your SSID: ")
client = AsyncPocketOptionClient(SSID, is_demo=True, enable_logging=False)
await client.connect()
balance = await client.get_balance()
print(f"Your balance is: {balance.balance}, currency: {balance.currency}")
await client.disconnect()
if __name__ == "__main__":
import asyncio
asyncio.run(main())
where the ssid should look something like this: 42["auth",{"session":"n1p5ah5u8t9438rbunpgrq0hlq","isDemo":1,"uid":0,"platform":1}]
i had the same issue. there are two ssid's one for demo and one for real. it depends on which URL you are on. the auth i found to be working on demo looks like this: 42["auth", {"session":"SessionKeyHere","isDemo":1,"uid":12345678,"platform":2,"isFastHistory": true,"isOptimized": true}]