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
Disconnect after some time #648
Comments
@kwiiby I am getting the same issue too. I have run my script as a background process but it still disconnects - (nohup python -u ./myscript.py > ./mylog.log &) I am thinking of a work around like this. Create a thread that keeps on checking a flag in a db of whether the whatsapp connection is still on in intervals of lets say 5 seconds. |
@mutindaz @kwiiby A simple workaround is to put the echo client in a bash script. |
@gautammaloo I will try that.
|
Why not everything in the same script? create a layer with a thread for broadcast.. |
About the issue, the ping wasn't working because YowIqProtocolLayer wasn't in the tuple below EchoLayer.. (in the stack) |
This is how i handled this issue. I listen for "DISCONNECTED" event state and login again def onEvent(self, layerEvent):
if layerEvent.getName() == YowNetworkLayer.EVENT_STATE_DISCONNECTED:
self.log("Disconnected: %s" % layerEvent.getArg("reason"))
self.connected = False
reactor.callLater(2,self.login)
elif layerEvent.getName() == self.__class__.EVENT_NETWORK_CONNECTED:
self.connected = True
return False |
Well, I don't want to dive into why I chose that approach but having YowIqProtocolLayer in your layers turple works. @gisho do I have to create the EVENT_STATE_DISCONNECTED defined in my stack because I am only getting EVENT_NETWORK_CONNECTED only in onEvent ? |
@mutindaz the even is already defined here |
@kwiiby could you explaint your solution more. How I can have the ping every 30 seconds in my script? Thanks |
Just append YowIqProtocolLayer to layers = () in your stack.py (should be in the first turple..) |
I have done it but the script disconnect randomly. Monitoring the network I can see the periodic ping but sometime it miss one and the cliente disconnect. There is a way to send ping every 30 sec instead of 120? |
@gisho I also tried it like your method, but it gets disconnected before it could listen to EVENT_STATE_DISCONNECT or EVENT_STATE_DISCONNECTED. it prints only these two events: |
try @kwiiby suggestions its working for me. i figured the the disconnected event is not propergating correctly on detached queue. you can remove ``detached = False self.emitEvent(YowLayerEvent(self.__class__.EVENT_STATE_DISCONNECTED, reason = reason, detached=True)) to self.emitEvent(YowLayerEvent(self.__class__.EVENT_STATE_DISCONNECTED, reason = reason)) |
What did the trick for me was adding these parameters to the stack.loop call: stack.loop(timeout = 0.5, discrete = 0.5) #this is the program mainloop Found these in the CLI demo |
Hello, I'm using the echoclient and I'm not familar with Python. So, I would be very happy if some body can give me a working echoclient with an implemented ping. Thanks a lot. |
@jowiemann as @prasselpikachu pointed out, open stack.py in the echoclient demo then edit the following lines.
to
|
Thank you, works very well. |
@jowiemann welcome. |
Hmm. I've done the following:
I am using the demo echoclient. Still after those changes, the client disconnects. I can reconnect once, and still get it to echo messages properly. But, then it will disconnect again. Then I reconnect again, but this time the message queue is not being processed. :-( After a reboot, I get two more chances like above then it stops working again.... I can reproduce this behaviour very easily. |
Hello, Your sincerly Joerg |
@jowiemann Make sure you update to the latest version of Yowsup. My problems were solved by doing so. |
@Serilium thank you for your answer. I've done already an update, but the Problem is still the same. |
Don' working for me :( |
Not working for me as well. I cloned the latest code and added the timeout and discrete parameters in my Python main code :( So to elaborate a little bit more: The client doesn't get disconnected, but it stops processing messages. |
I happen like @idigevian , I can´t receive messages. Help me please!! |
I am also seeing lots of "Disconnected, reason: Connection Closed" |
any news? Thks! |
#915 may just solve it |
I still have the same problem with last clone on raspberryPI
and
Any workaroud ? |
Hello, unfortunately I still got the problem that yowsup disconnects. But it's very random. I got YowIqProtocolLayer in my layers and I got the parameters at stack.loop: I tried all workarounds and solutions I could find but nothing worked so far. |
this isn't definitive solution for errors. run stack.start() in a daemon mode thread. |
HI, rudepython, I am pretty new in yowsup. This mean That I can replace the typical /disconnect from the yowsup-cli by a event_disconnect on the code using the stacks... modules. any Idea, how put this event_disconnect on a thread code in oder to get connect and disconnect in every iteration with a time.sleep(5), for example. I appreciate your help. |
I have the same problem (Yowsup on Debian). This code bellow runs correctly, but stop running after some minutes. How to do? === run.py ===
=== layer.py ===
|
Have same problem 8(
I'm afraid lopped reconnects may be not best solution - whatsapp can detect it and ban account. |
I'm trying to solve the problem using this code but still testing
|
With the code obove it is running now for 3 days without problems. I also set to 2.5 seconds the ping timeout. |
ToninoTarsi, in which layer this code should be implemented? |
Is this a example?
|
hey.. I am using echoclient (latest release 2.2.78) and it is disconnecting after some random time, it doesn't receive messages anymore (none event is fired onEvent)
I already have a thread to ping whatsapp every 30 seconds in my layer.. here it is:
I also tried to use YowIqProtocolLayer, but it gives org.openwhatsapp.yowsup.event.network.disconnect after some time too.
So, what should I do?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: