BinaryOptionsTools-v2 icon indicating copy to clipboard operation
BinaryOptionsTools-v2 copied to clipboard

Windows 10 + Python 3.8 - WebSocket connects then immediately closes (Authentication timeout)

Open mikkyoff opened this issue 7 months ago • 10 comments

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?

mikkyoff avatar Apr 23 '26 04:04 mikkyoff

Hello! @Rick-29 could you tell us what happened here?

In the meantime, would you be okey sharing the relevant part of your code?

theshadow76 avatar Apr 23 '26 06:04 theshadow76

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'

mikkyoff avatar Apr 23 '26 06:04 mikkyoff

I see, you are using the old repository, you need to use BinaryOptionsToolsV2 for the latest version

theshadow76 avatar Apr 23 '26 08:04 theshadow76

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.

mikkyoff avatar Apr 23 '26 13:04 mikkyoff

@theshadow76 @Rick-29

Plaese, come to my aid. I've been struggling with this since sunday. Kindly check my last message above. Thanks.

mikkyoff avatar Apr 24 '26 03:04 mikkyoff

Make sure to run this command:

pip uninstall websockets; pip install websockets==11.0

theshadow76 avatar Apr 24 '26 08:04 theshadow76

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.

mikkyoff avatar Apr 24 '26 10:04 mikkyoff

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?)

sixtysixx avatar Apr 26 '26 06:04 sixtysixx

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

theshadow76 avatar Apr 26 '26 11:04 theshadow76

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)

Image For example here with a period of 10 and an offset of 60 it returns 6 candles (as expected as number of candles is more or less equal to offset / period).

Rick-29 avatar Apr 26 '26 12:04 Rick-29