Reputation: 5946
I'm using aiohttp to post multiple times, but I find an issue that means that I never get beyond the first post. Code then hangs for a while and produces the below error.
async def posted(URL, payload):
#'Content-Type': 'application/json'}
headers = {'User-Agent': get_random_user_agent(),
'ngrok-skip-browser-warning': '100'}
async with aiohttp.ClientSession(URL, headers=headers) as session:
for i, data in enumerate(payload):
if data[0] is not None and data[1] is not None:
print(data[1], len(data[0]))
myobj = {'url_input': data[1], 'text_input': data[0]}
encoded_data = parse.urlencode(myobj).encode()
async with session.post('/', json=myobj):
print('posted')
#await session.close()
The call is as follows:
await posted(URL, work_list)
where
work_list = [('content', 'url'),('content1', 'url1')]
The error is as follows:
The above exception was the direct cause of the following exception:
ClientOSError Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/aiohttp/streams.py in read(self)
669 self._waiter = self._loop.create_future()
670 try:
--> 671 await self._waiter
672 except (asyncio.CancelledError, asyncio.TimeoutError):
673 self._waiter = None
ClientOSError: [Errno 1] [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2580)
As pointed out this could be due to ngrok being https and forwarding to HTTP. So I created an ad-hoc SSL in flask application and restarted ngrok, but now I do not see any information coming through on debug and the similar problem cropping up.
Upvotes: 0
Views: 31