Windows 10 + Python 3.8 - WebSocket connects then immediately closes (Authentication timeout)
I'm trying to use the Pocket Option API on Windows 10 with Python 3.8. The SSID format is correct and works in the browser, but the WebSocket connection drops immediately after connecting.
What happens:
Connects successfully to wss://demo-api-eu.po.market
Handshake completes
Then immediately: WebSocket connection closed
Error: Authentication timeout - server did not respond
My environment:
OS: Windows 10
Python: 3.8.10
Library: pocketoptionapi-async 2.0.1
Network: Home internet (Nigeria)
My SSID format (redacted):
text 42["auth",{"session":"xxx","isDemo":1,"uid":xxx,"platform":2}] This exact SSID works in my browser. The same code runs without issues on Linux. Is this a known Windows-specific WebSocket issue?
Hello! @Rick-29 could you tell us what happened here?
In the meantime, would you be okey sharing the relevant part of your code?
from pocketoptionapi_async import AsyncPocketOptionClient
SSID = '42["auth",{"session":"xxx","isDemo":1,"uid":xxx,"platform":2}]'
async def test(): client = AsyncPocketOptionClient(ssid=SSID) await client.connect() candles = await client.get_candles("EURUSD_otc", period=60, limit=10)
This is the error im getting BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'
I see, you are using the old repository, you need to use BinaryOptionsToolsV2 for the latest version
WebSocket connection fails on Windows and Railway (extra_headers error + channel closed)
Environment
- OS: Windows 10 / Railway (Linux)
- Python: 3.12, 3.11, 3.8 (tested multiple versions)
- Library: BinaryOptionsToolsV2 (also tested pocketoptionapi_async)
- SSID format: Confirmed correct by developer
Problem
The WebSocket connection fails in two different ways depending on platform:
On Windows:
- Authentication succeeds, connection appears ready
client.get_candles()fails with:ValueError: PocketOptionError, Core error: Channel sender error: send to a half closed channel- Balance returns
$-1.0(demo account)
On Railway (Linux):
- Connection fails immediately with:
BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'
Code that reproduces the issue
from BinaryOptionsToolsV2 import PocketOption
SSID = '42["auth",{"session":"xxx","isDemo":1,"uid":xxx,"platform":2}]'
client = PocketOption(ssid=SSID)
client.connect()
print("Connected!") # This succeeds on Windows
print(f"Balance: {client.balance()}") # Returns $-1.0
# This fails on Windows:
candles = client.get_candles("EURUSD_otc", 60, 10) # ❌ Channel sender error
Expected behavior
Should fetch candles successfully after authentication
Actual behavior
WebSocket channel closes after authentication on Windows
Connection fails entirely on Railway/Linux
Error on Windows:
ValueError: PocketOptionError, Core error: Channel sender error: send to a half closed channel
Error on Railway:
BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'
Questions
Is this a known Windows-specific WebSocket issue?
Does the library require a specific Python version?
Are there any working examples of get_candles() on Windows?
Thank you for your work on this library. Happy to provide any additional debugging information.
@theshadow76 @Rick-29
Plaese, come to my aid. I've been struggling with this since sunday. Kindly check my last message above. Thanks.
Make sure to run this command:
pip uninstall websockets; pip install websockets==11.0
I've spent 15+ hours debugging BinaryOptionsToolsV2. Here's the situation:
✅ Authentication works
✅ Connection works
✅ Balance works (returns $-1.0 for demo)
❌ get_candles() ALWAYS fails with: "Channel sender error: send to a half closed channel"
I used websockets==11.0 as instructed in the last message
This happens on:
- Windows 10 (Python 3.11, 3.12, 3.13)
- Railway (Linux, Python 3.11)
- Both sync and async clients
The SSID is correct and works in the browser. The WebSocket connects successfully but the channel closes when trying to fetch candles.
Is there a working example of get_candles()? Is there a different method to fetch historical candle data?
Please help - I've tried everything.
I believe this is on PO's side, other users have been having the same issue and its often with excessive get_candles requests, also, "you" said ✅ Balance works (returns $-1.0 for demo), which should realistically return your demo account balance, such results tell me you haven't set a delay between connection and retrieving balance. (and likely using AI to assist with this for some reason? Is it really that hard?)
it is recommended to use asyncio.sleep() right afer the connection, like this:
import asyncio
from BinaryOptionsToolsV2.pocketoption import PocketOptionAsync
async def main(ssid: str):
# The api automatically detects if the 'ssid' is for real or demo account
api = PocketOptionAsync(ssid)
await asyncio.sleep(5)
....
if __name__ == "__main__":
ssid = input("Please enter your ssid: ")
asyncio.run(main(ssid))
also I recommend using subscribe_symbol_timed instead of get_candles
if you still need help, just send another message here or in discord: https://discord.gg/mQzRmw4Dfr
WebSocket connection fails on Windows and Railway (extra_headers error + channel closed)
Environment
- OS: Windows 10 / Railway (Linux)
- Python: 3.12, 3.11, 3.8 (tested multiple versions)
- Library: BinaryOptionsToolsV2 (also tested pocketoptionapi_async)
- SSID format: Confirmed correct by developer
Problem
The WebSocket connection fails in two different ways depending on platform:
On Windows:
- Authentication succeeds, connection appears ready
client.get_candles()fails with:ValueError: PocketOptionError, Core error: Channel sender error: send to a half closed channel- Balance returns
$-1.0(demo account)On Railway (Linux):
- Connection fails immediately with:
BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'Code that reproduces the issue
from BinaryOptionsToolsV2 import PocketOption
SSID = '42["auth",{"session":"xxx","isDemo":1,"uid":xxx,"platform":2}]'
client = PocketOption(ssid=SSID) client.connect() print("Connected!") # This succeeds on Windows print(f"Balance: {client.balance()}") # Returns $-1.0
This fails on Windows:
candles = client.get_candles("EURUSD_otc", 60, 10) # ❌ Channel sender error
Expected behavior Should fetch candles successfully after authentication
Actual behavior WebSocket channel closes after authentication on Windows
Connection fails entirely on Railway/Linux
Error on Windows: ValueError: PocketOptionError, Core error: Channel sender error: send to a half closed channel
Error on Railway: BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'
Questions Is this a known Windows-specific WebSocket issue?
Does the library require a specific Python version?
Are there any working examples of get_candles() on Windows?
Thank you for your work on this library. Happy to provide any additional debugging information.
Hello, I executed the code and the error is the following, the parametters passed to the function are incorrect. The order is inversed, first is the period (the smallest number and then the offset, basically a number allways greater than the period)