python-schema-registry-client icon indicating copy to clipboard operation
python-schema-registry-client copied to clipboard

AsyncSchemaRegistryClient is unable to handle concurrent requests

Open thiromi opened this issue 3 years ago • 9 comments

Describe the bug

Related to https://github.com/encode/httpx/issues/1478, I'm getting this exception while using the same instance of AsyncSchemaRegistryClient in two different places, raising httpx.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE. The source code of the client is similar to the example that shows how to reproduce the issue in httpx and the answer to this comment mentions using the context manager once at a time would be the fix to it.

I could manage to overcome this issue by creating one instance of the client for every class that depends on AsyncSchemaRegistryClient

To Reproduce Steps to reproduce the behavior:

I'll need some time to write a small snippet to reproduce it, so bear with me 😬

Expected behavior

The client is able to handle two (or more) concurrent calls to the schema registry

thiromi avatar Dec 13 '21 13:12 thiromi

Hi @thiromi

I think after merging this PR https://github.com/marcosschroh/python-schema-registry-client/pull/117 the issue will be solved

marcosschroh avatar Feb 02 '22 11:02 marcosschroh

@thiromi can you check whether with the latest version this issue is fixed?

marcosschroh avatar Feb 09 '22 13:02 marcosschroh

@marcosschroh I'll try it and let you know 👍

thiromi avatar Feb 10 '22 10:02 thiromi

@thiromi Did #117 fix your issue?

bradydean avatar Mar 29 '22 15:03 bradydean

@marcosschroh sorry for the wait, but meh, I still face

httpx.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE

cc @bradydean

thiromi avatar Mar 29 '22 17:03 thiromi

@thiromi Are you using the same client object from different threads or asyncio tasks? Just curious as I'm about to start development using this library.

bradydean avatar Mar 29 '22 17:03 bradydean

@bradydean I'm using the same client from asyncio tasks

thiromi avatar Mar 30 '22 08:03 thiromi

According to httpx this error happens when Server closed without sending response. In one of the latest versions of httpx a warning was added related to this and the error message was improved. Which httpx version are you using?

marcosschroh avatar Apr 08 '22 14:04 marcosschroh

@marcosschroh I'm using httpx==0.22.0

thiromi avatar Apr 11 '22 16:04 thiromi