Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to keep a connection with InvenTree open #242

Open
realstudent01 opened this issue Sep 8, 2024 · 1 comment
Open

How to keep a connection with InvenTree open #242

realstudent01 opened this issue Sep 8, 2024 · 1 comment

Comments

@realstudent01
Copy link

I am making a front end dashboard to view some information in a database with the InvenTree API. Seemingly randomly I am getting the following errors:

"requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))"

"requests.exceptions.ChunkedEncodingError: ("Connection broken: ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)", ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))"

Is the issue that I need to do something to keep the api instance (that I initialize to make the connection) open? Or do I need to give a certain value as the timeout?

@SchrodingersGat
Copy link
Member

You should not assume that the connection attempt will always work - there can be timeouts, other interrupts, etc. I would wrap your code in a try / except block, and handle any failures accordingly. Probably just by re-attempting.

Adding a small delay between requests will probably help, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants