Comments (9)
Hi, @illpack !
I am sorry that I just describe my solution roughly.
I recommend to use requests
package, and call the API through the URL instead of SDK.
The below one is an example source code.
from requests import Response, Session
class Mixpanel:
def __init__(self):
self.session: Sesison = Session()
self.adapter: HTTPAdapter = HTTPAdapter(max_retries=20)
self.session.mount("htttps://", adapter=self.adapter)
self.session.mount("http://", adapter=self.adapter)
def track(self, username, event_name, data={}, request=None):
response: Response = self.session.post(
url="https://api.mixpanel.com/track",
headers={
"Accept": "text/plain",
"Content-Type": "application/json",
"Connection": "close". # This header is my solution.
},
json=[
{
"event": YOUR_EVENT_NAME,
"properties": {
"token": YOUR_TOKEN,
...
},
}
],
)
If you want to use asynchronous HTTP requests, you can use aiohttp
package instead of requests
.
I think there are no ways to change the header parameters if you use the SDK.
You can check the all API lists from the documents, and if you want to use the track
method -API-, check Track Events
from mixpanel-python.
Thanks a lot @0417taehyun that looks reasonable, I will try your approach.
from mixpanel-python.
Sure thing @0417taehyun I will give it a try shortly and monitor it and keep you posted!
from mixpanel-python.
Same problem here - any hints?
from mixpanel-python.
Hi, I solved this issue to change the Connection
header argument.
The default value is keep-alive
, and I change it to close
.
from mixpanel-python.
Hi @0417taehyun I am glad you managed to solve it! I am using the Mixpanel client for Python, but can't see a clear reference to your solution, could you maybe provide a small example of how you applied it?
This is my implementation:
from mixpanel import Consumer, Mixpanel
class MixpanelClient:
def __init__(self):
self.client = Mixpanel(
MXP_TOKEN,
consumer=Consumer(api_host=MXP_HOST),
)
self.api_key = MXP_API_KEY
async def track(self, username, event_name, data={}, request=None):
[...]
self.client.track(username, event_name=event_name, properties=data)
Thanks a lot!
from mixpanel-python.
I am glad I could help you! Would you mind sharing whether my approach works for your situation or not?
I am curious to know if it's successful.
from mixpanel-python.
Hi @0417taehyun I have deployed your solution this morning and it seems to have solved the issue, it has not ocurred again in the last 4 hours. Thank you!! 🎉
from mixpanel-python.
Hi, @illpack !
It is glad to hear that you solve the issue! Have a nice day 😄
from mixpanel-python.
Related Issues (20)
- Connection reset by peer from BufferedConsumer HOT 10
- A way to register super properties HOT 1
- Async support HOT 7
- Missing APIs HOT 1
- how to do mixpanelGetEventsForProfiles HOT 1
- Pass `ip` event property HOT 1
- `import_data` does not work with Service Accounts due to missing `project_id` HOT 2
- Decimal values are not serializable as JSON in properties
- Clarify documentation for meta argument
- BufferedConsumer max_size limited to 50 HOT 1
- time_event functionality not available
- ConnectionResetError(104, 'Connection reset by peer') HOT 6
- Missing types for mypy HOT 2
- Mixpanel tracking is not working HOT 1
- Track time is sent in seconds
- Remove python 2.7 support
- Identify method is missing HOT 1
- mixpanel.MixpanelException: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) HOT 4
- 443 max retries exceeded error ['[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol] HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mixpanel-python.