Skip to content

[Pyamqp] Revert back to websocket-client - #26787

Closed
kashifkhan wants to merge 6 commits into
Azure:feature/eventhub/pyprotofrom
kashifkhan:eh_py_rev_ws
Closed

[Pyamqp] Revert back to websocket-client#26787
kashifkhan wants to merge 6 commits into
Azure:feature/eventhub/pyprotofrom
kashifkhan:eh_py_rev_ws

Conversation

@kashifkhan

Copy link
Copy Markdown
Member

aiohttp websocket has 2 bugs when a connection is abruptly cut:

  • websocket send does not throw an exception -> issue -> known since 2017

  • websocket receive gets stuck if network is suddenly disconnected -> PR -> unmerged since July 2021

Reverting back to websocket-client in async as that is what most are using. There is another async websocket client but it doesnt support proxies.

@kashifkhan

Copy link
Copy Markdown
Member Author

/azp run python - eventhub - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

await self.write(data)
# _LOGGER.info("OCH%d -> %r", channel, frame)

class AsyncTransport(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we copy changes to SB pyamqp as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes these changes will have to go back there too

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I meant can you copy them over in this PR? 🙂
or do we want to do that later?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol my reply wasnt clear, Ill do it in this PR itself :)

raise ValueError("Please install websocket-client library to use websocket transport.")

async def _read(self, n, buffer=None, **kwargs): # pylint: disable=unused-argument
async def _read(self, n, buffer=None, **kwargs): # pylint: disable=unused-arguments

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be a typo and need to be

Suggested change
async def _read(self, n, buffer=None, **kwargs): # pylint: disable=unused-arguments
async def _read(self, n, buffer=None, **kwargs): # pylint: disable=unused-argument

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this will be a lot of work, but would you be able to compare with the sync transport/websocket to see if there were changes that need to be copied over here? I think I may have added some mypy/pylint things?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a lot of work, I just brought in the old WebSocketTransportAsync and the current portions untouched. Any re-shuffling will keep all the pylint/mypy work. Will take a look at the WebSocketTransportAsync though

@azure-sdk

Copy link
Copy Markdown
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-eventhub

@kashifkhan

Copy link
Copy Markdown
Member Author

/azp run python - eventhub - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@kashifkhan

Copy link
Copy Markdown
Member Author

/azp run python - eventhub - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@kashifkhan

Copy link
Copy Markdown
Member Author

/azp run python - eventhub - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@kashifkhan

Copy link
Copy Markdown
Member Author

/azp run python - eventhub - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@kashifkhan

Copy link
Copy Markdown
Member Author

/azp run python - eventhub - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@kashifkhan

Copy link
Copy Markdown
Member Author

Due to issues with running websocket-client in async mode, we decided to stay with aiohttp for async. We were able to use heartbeat from aiohttp and timeouts to mitigate the bugs.

@kashifkhan kashifkhan closed this Oct 25, 2022
@gil-cohen

Copy link
Copy Markdown

@kashifkhan im having the same issue, can you elaborate on what you did with aiohttp, which timeouts did you use?

@kashifkhan

Copy link
Copy Markdown
Member Author

@kashifkhan im having the same issue, can you elaborate on what you did with aiohttp, which timeouts did you use?

@gil-cohen I passed in heartbeat parameter in ws_connect with a value of 10 seconds. That was enough time for the library to determine that the underlying connection has been lost.

Additionally you can take a look at these 2 PRs where you can see the changes and some of the exceptions that I am now addressing

#26856
https://github.com/Azure/azure-sdk-for-python/pull/27006/files

@kashifkhan
kashifkhan deleted the eh_py_rev_ws branch November 29, 2022 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants