ekulyk / pythonpusherclient Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
When we receive some data, the callback is called in the web socket channel's thread. It can lead to serious issues when mixed with other non thread-safe calls.
Hi,
When trying to run pythonpucherclinet
I always get the error saying: cafile, capath and cadata cannot be all omitted
I've been using your PythonPusherClient module and as of yesterday it broke for no known reason. None of the code I use has been changed, it just broke.
Connection: Message - {"event":"pusher:error","data":{"code":4005,"message":"Path not found"}}
Connection: Unhandled event
Connection: Error -
Connection: Connection closed
Attempting to connect again in 10 seconds.
Here below is the error message :
Unhandled exception in thread started by <bound method Connection.run of <Connection(Thread-1, initial)>>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pusherclient-0.2.0-py2.7.egg/pusherclient/connection.py", line 88, in run
self._connect()
File "/usr/local/lib/python2.7/dist-packages/pusherclient-0.2.0-py2.7.egg/pusherclient/connection.py", line 111, in _connect
self.socket.run_forever()
File "/usr/local/lib/python2.7/dist-packages/websocket/_app.py", line 179, in run_forever
self.sock.close()
File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 810, in close
self._closeInternal()
File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 813, in _closeInternal
self.sock.close()
AttributeError: 'NoneType' object has no attribute 'close'
Thankx to have a look on it,
Arnaud
Adding tests and hooking up something like travis would be really helpful!
Hello! We're currently using the dev branch directly to get the secure-option.
Is there a released planned anytime soon so that we can go back to using the real release? =)
Thanks!
After a few minutes of not receiving data, I see in the console:
Did not receive any data in time. Reconnecting.
Connection: Error - [Errno 35] Resource temporarily unavailable
Connection: Connection closed
Attempting to connect again in 10 seconds.
Connection: Connection opened
Connection: Connection closed
Attempting to connect again in 10 seconds.
The API documentation says: "In protocol versions 5 and above, when using an old version of the WebSocket protocol, Pusher will send pusher:ping event (see events) to the client. The client should respond with a pusher:pong event." I don't see any ping events coming through, though.
Have you considered releasing this package on pypi.python.org?
That would simplify the package installation a lot.
Hey @ekulyk, Adam from Pusher here.
We've been contacted by several of our customers as this library supports a version of our protocol that is <= version 3, and we are sending warnings out to customers warning that we are going to be deprecating these versions of the API shortly. We plan to finish deprecating these versions before the New Year.
In order to keep this library usable for you and your users, could you please ensure that the library is upgraded to a later version of the protocol (preferably version 6)? Please contact me directly if you'd like me to assist you in any way with this. :)
Hi there,
when trying to use the lib, hmac is throwing errors because msg in hmac.new() is a string and should be byte or bytearray.
Greets
It is currently impossible to set a user-defined reconnect interval, since the variable self.reconnect_interval is set to the function argument of the reconnect() function every time it is called.
The quickest way to implement this feature is to let the default value of reconnect_interval in the reconnect function point to an instance variable.
I got next errors when I try to use last version of websocket (0.56.0):
error from callback <bound method Connection._on_open of <Connection(Thread-8, started daemon 14424)>>: _on_open() missing 1 required positional argument: 'ws'
error from callback <bound method Connection._on_message of <Connection(Thread-8, started daemon 14424)>>: _on_message() missing 1 required positional argument: 'message'
It works good if I downgrade websocket-client to version 0.48.0.
It seems like according to recent changes of websocket-client, the callback function does not receive WebSocketApp instance if it is a method of any class.
The server I'm connecting to seems to close the connection after some time. I would like to handle this event (re-establishing the connection). From what I can see in the code pusherclient doesn't seem to expose the close handler of websocket-client WebSocketApp. Instead only a log is written and timers stopped via the following code:
def _on_close(self, ws, *args):
self.logger.info("Connection: Connection closed")
self.state = "disconnected"
self._stop_timers()
Is there a way to handle the connection close with pusherclient without modifying it?
I was wondering if this project is still alive.
If not do you know of a replacement project?
I'm trying to write some code that'll handle a fixed number of events then exit. The natural way to do this seems to be calling Pusher.disconnect()
from a handler once it's seen enough events.
But since the callbacks are fired from within Pusher's connection thread and disconnect()
ends in a Thread.join(), this results in a RuntimeError
.
Example code:
import time
import pusherclient
class MyClient(object):
STOP_AT_N = 5
def __init__(self):
super(MyClient,self).__init__()
self.n_events = 0
def connect(self):
"Connect to a random Pusher channel & consume events"
self.pusher = pusherclient.Pusher('de504dc5763aeef9ff52')
def event_handler(e):
self.n_events += 1
print("event %d" % (self.n_events,))
if self.n_events >= self.STOP_AT_N:
self.pusher.disconnect()
def connect_handler(data):
channel = self.pusher.subscribe('live_orders')
channel.bind('order_created', event_handler)
self.pusher.connection.bind('pusher:connection_established', connect_handler)
self.pusher.connect()
if __name__ == '__main__':
mc = MyClient()
mc.connect()
while True:
time.sleep(1)
What happens for me:
$ python3 experiments/pusher_handler_disconnect.py
event 1
event 2
event 3
event 4
event 5
error from callback <bound method Connection._on_message of <Connection(Thread-1, started daemon 123145422946304)>>: cannot join current thread
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.