Possible ways to bypass roadblocks?
Inquiry
Maintaining many connections at once.
Context
Hi, me again. In my project I have a lot of assets to watch simultaneously (26-29). But the farthest that I could go is 4 assets for 1 API.
So I created 8 different SSIDs and tried distributing all the symbols evenly (4 per API) across all of them. But the farthest I could go was 2 random API connecting simultaneously. So I'm asking, is my approach adecuate, or should I rethink the connection process completely?
Here's some comprehensible debug output for better understanding:
New API created, index: 0
New API created, index: 1
New API created, index: 2
New API created, index: 3
New API created, index: 4
New API created, index: 5
New API created, index: 6
Total APIs created: 7
Failed to subscribe AEDCNY_otc on connection 1: PocketOptionError, Core error: Channel sender error: send to a half closed channel
Failed to subscribe AUDCHF_otc on connection 2: PocketOptionError, Core error: Channel sender error: send to a half closed channel
Failed to subscribe AUDNZD_otc on connection 3: PocketOptionError, Core error: Channel sender error: send to a half closed channel
Here I create 7 APIs because I have to watch 26 different assets at once.
P.S if this can in any way give some more context, I've also added some considerable timeouts between requests to try to prevent the server from detecting malicious activity.
Environment
- macOS Tahoe 26.4
- 3.12
- Latest
Resources Checked
- [v] Documentation
- [v] Existing Examples
- [v] Previous Issues
Hello and nice to meet you,
I would recommend using a proxy server for each connection.
Here is a proxy provider I would recomend using that I believe it should work for this
I already use a proxy. Digging further I've tried to add a testing attempt for each SSID to create one subscription. This went wrong on the very first one, so I started looking if the ssid would change over some time, and it happened to be true.
Are the SSIDs temporary or I can use them at any time?
Ah, you are using the real ssid? For this I recomend using demo ssid.
Could you send the code? The error looks more like if the data was dropped somewhere on your code since your idea should work and i managed to connect to pocket option with multiple instances of the PocketOption class (with the same ssid) concurrently.
I believe that 4 is the absolute max with one SSID without it unsubscribing you to one stream. As per you can only have 4 active charts on the GUI.
You could try to bypass this by constantly determining if you've been disconnected and reconnect automatically, but it's probably not a very surefire solution.
You could always try using different docker containers, but I dont really know if this would actually work or not. But you could try!
Thank you all for your time and the possible actions provided. Firstly, I'd want to clarify the situation as there might be some misunderstanding.
I've tested 8 different SSIDs with 4 random assets simultaneously (but one seed at a time), and every one worked just fine. But when, on the next day I wanted to watch all the 26 assets at once, almost every SSID returned this "half closed channel error", except for 1-2 random ones. Now I'm back at testing SSIDs one by one, trying this code:
ssid = config.SSID1.get_secret_value()
api = PocketOptionAsync(ssid)
await asyncio.sleep(5)
try:
candles = await api.get_candles("AEDCNY_otc", 30, 480)
print(candles)
except Exception as e:
print(f"Not handled, {e}")
And it returns the same old PocketOptionError, Core error: Channel sender error: send to a half closed channel.
I would love if you explained me how to obtain proper SSID from demo pages because their auth websocket message only contains 3 fields, missing the "session" one. And it is crucial for the program's work. So at this point I totally would like to use the demo, but I'm stuck at the accounts problem.
Another question is that these SSIDs, to my opinion, totally need constant updates, as I don't see no other reason for them to drop the connection. Hoping to be wrong in this case)
Could you send the code? The error looks more like if the data was dropped somewhere on your code since your idea should work and i managed to connect to pocket option with multiple instances of the PocketOption class (with the same ssid) concurrently.
Here's the code that doesn't work for me, all the SSIDs are real accounts which have worked properly at least once, on the testing stage for each one.
async def main():
ssids = [config.SSID1, config.SSID2, config.SSID3, config.SSID4, config.SSID5, config.SSID6, config.SSID7, config.SSID8]
apis = []
streams = []
suitable_assets = ['AEDCNY_otc', 'AUDCHF_otc', 'AUDNZD_otc', 'AUDUSD_otc', 'CADCHF_otc', 'EURJPY_otc', 'EURTRY_otc', 'EURUSD_otc', 'GBPUSD_otc', 'JODCNY_otc', 'LBPUSD_otc', 'NGNUSD_otc', 'NZDUSD_otc', 'QARCNY_otc', 'USDBDT_otc', 'USDBRL_otc', 'USDCAD_otc', 'USDCHF_otc', 'USDCOP_otc', 'USDDZD_otc', 'USDIDR_otc', 'USDJPY_otc', 'USDMXN_otc', 'USDPKR_otc', 'USDSGD_otc', 'USDTHB_otc']
apis_needed = 7 if len(suitable_assets) <= 28 else 8
for i in range(apis_needed):
api = PocketOptionAsync(ssids[i].get_secret_value())
if api:
print("New API created, index:", i)
else:
print("Failed to create", i, "API")
apis.append(api)
await asyncio.sleep(10)
try:
stream = await api.subscribe_symbol("AEDCNY_otc")
except Exception as e:
print(f"Faulty API #{i}, no stream was created: {e}")
await api.unsubscribe("AEDCNY_otc")
print(len(apis))
for i, asset in enumerate(suitable_assets):
api_index = i % len(apis)
api = apis[api_index]
try:
stream = await api.subscribe_symbol(asset)
streams.append(stream)
print(f"[{asset}] -> connection {api_index + 1}")
except Exception as e:
print(f"Failed to subscribe {asset} on connection {api_index + 1}: {e}")
await asyncio.sleep(3.5 + uniform(0, 5))
print(len(streams), "streams opened")
if not streams:
print("No streams opened")
return
await asyncio.gather(*(candleLogic(stream) for stream in streams))
if __name__ == "__main__":
asyncio.run(main())
I've added this test subscription for AED/CNY for each API to determine the faulty ones more quickly, it has no impact on the issue, the code did not work without it.
Interesting, I can maybe look at this when I have the time.
That'd be very nice of you. But what about those demo account SSIDs, or time constraints to the real SSIDs? Are my assumptions right or I don't know something?
That'd be very nice of you. But what about those demo account SSIDs, or time constraints to the real SSIDs? Are my assumptions right or I don't know something?
I dont believe SSIDs expire, or at least for a long time- the only ways I know that you can force an SSID out of auth is:
- changing IP associated with the account (not 100% sure)
- changing auth methods- such as the password used to login
- iirc, demo accounts change much more often than real accounts.
Im also wondering if your proxy provider has to do something with it. Is it a static proxy? And how are you using it with each request- proxychain-ng, or something else?
Sorry about the delayed, I havent been able to work on this too much.
Best, Syx
if you still need help please open another issue or contact us at https://chipatrade.com/support