-
Notifications
You must be signed in to change notification settings - Fork 85
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
Connection reset by peer from BufferedConsumer #104
Comments
Hello @dkarp0, can you provide the |
Hey @seizethedave, I might try switching away from the |
Hm, older ones have issues. Certainly fewer people use the buffered consumer. I might try reproing by using the buffered consumer with longer and longer periods of inactivity. But you’ll have to bear with me as I’m out of the office for a while. |
@seizethedave Is mixpanel-python exposing the connection details somewhere so I can do that? I haven't dived into how the BufferedConsumer is functioning. Difficulty is that we only enable mixpanel on our deployed environments so I'm not able to reproduce locally. |
I'm back from my leave, thanks for being patient. I take it this is still an issue for you?
No, there are no connection details exposed. Would probably have to make some changes to the library to introspect the connection age/etc and log those when there's an RST. (Haven't looked into it!) |
@seizethedave I switched to the regular Consumer class and still got the same issue. So I looked into why the switch to We initialised the mixpanel library when initialising our Flask app, but then called Fix was to wrap initialising the mixpanel library in a closure, so it happens on the background thread instead of when we initialise the app. It'd be nice if that wasn't necessary though, maybe initialising the requests Session could be lazy and only happen when it's first needed |
This afternoon I found some time to rig up some threaded tests and I did get a "connection reset by peer" when tracking intermittently with ~20 threads after about 20 minutes. About how many threads was your application using? @dkarp0 |
The fix for this might be to avoid declaring the Mixpanel client globally? 4.9.0 started using a session from the requests library, and session will use a connection pool according to this: psf/requests#4784 (comment) The connections are probably getting reset after they're sticking around in the pool for a while. Avoiding declaring the client globally should avoid keeping the pool around between requests. |
We're still hitting this issue. Not declaring the Mixpanel client globally doesn't really solve the problem if you're using the BufferedConsumer to reduce the number of api calls. Any other option? |
Here is a proposed fix that has been working for us: #116 |
Since upgrading to 4.9.0, we've been getting the following error appearing frequently in sentry:
This only started after upgrading and seems to be to do with the switch the requests. It happens when we flush the consumer.
The text was updated successfully, but these errors were encountered: