yowsup icon indicating copy to clipboard operation
yowsup copied to clipboard

run.py and layer.py Disconnected

Open hostman89 opened this issue 11 years ago • 14 comments

I have a problem with app layer.py and run.py. this is my problem after 60 seconds :

DEBUG:yowsup.layers.logger.layer:rx: stream:error </stream:error>

DEBUG:yowsup.layers.network.layer:Disconnected, reason: Connection Closed DEBUG:yowsup.layers.network.layer:Disconnected, reason: Connection Closed

I managed to solve yousup -cli demmos , the client no longer disconnects. I yousup -master and updated but the problem persists and layer.py run.py . anyone know any solution? I have tried many solutions and not work. Thank you very much and sorry for my English .

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

hostman89 avatar Jun 16 '15 17:06 hostman89

It seems the same problem described in #689, #775, #808, #810.

Do you have correctly managed receipts in your code? Do you have a function like this:

    @ProtocolEntityCallback("receipt")
    def onReceipt(self, entity):
        ack = OutgoingAckProtocolEntity(entity, "receipt")
        self.toLower(ack)

Could be a problem with ping thread? Can you give some logs of rx/tx layer?

jlguardi avatar Jun 18 '15 08:06 jlguardi

Sorry for the delay , the problem has been solved by incorporating the bed YowIqProtocolcocoLayer in run.py. Now my disconnection is arbitrary and gives me this error: iq : ID : 180 Type : result from: [email protected]

Auth Error , reason Unhandled stream : node error: \ < stream: error> \ < xml -not- well-formed > \ < / xml -not- well-formed > \ < / stream : error >

Anyone know why this happens ? Thank you very much in advance and jlguardi

hostman89 avatar Jun 22 '15 15:06 hostman89

Same error here, once or twice a day

File "/usr/local/lib/python2.7/dist-packages/yowsup/stacks/yowstack.py", line 167, in loop
    asyncore.loop(*args, **kwargs)
  File "/usr/lib/python2.7/asyncore.py", line 216, in loop
    poll_fun(timeout, map)
  File "/usr/lib/python2.7/asyncore.py", line 156, in poll
    read(obj)
  File "/usr/lib/python2.7/asyncore.py", line 87, in read
    obj.handle_error()
  File "/usr/lib/python2.7/asyncore.py", line 83, in read
    obj.handle_read_event()
  File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event
    self.handle_read()
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/network/layer.py", line 72, in handle_read
    self.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/network/layer.py", line 79, in receive
    self.toUpper(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/stanzaregulator/layer.py", line 28, in receive
    self.processReceived()
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/stanzaregulator/layer.py", line 48, in processReceived
    self.toUpper(oneMessageData)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/auth/layer_crypt.py", line 63, in receive
    self.toUpper(payload)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/coder/layer.py", line 35, in receive
    self.toUpper(node)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/logger/layer.py", line 14, in receive
    self.toUpper(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 55, in toUpper
    self.__upper.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 160, in receive
    s.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init__.py", line 101, in receive
    recv(node)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/auth/layer_authentication.py", line 79, in handleStreamError
    raise AuthError("Unhandled stream:error node:\n%s" % node)
yowsup.layers.auth.autherror.AuthError: Unhandled stream:error node:
<stream:error>
<xml-not-well-formed>
</xml-not-well-formed>
</stream:error>

raooll avatar Jun 23 '15 04:06 raooll

try this ... file run.py from yowsup.stacks import YowStack from layer import EchoLayer from yowsup.layers import YowLayerEvent from yowsup.layers.auth import YowCryptLayer, YowAuthenticationProtocolLayer, AuthError from yowsup.layers.coder import YowCoderLayer from yowsup.layers.network import YowNetworkLayer from yowsup.layers.protocol_messages import YowMessagesProtocolLayer from yowsup.layers.protocol_media import YowMediaProtocolLayer from yowsup.layers.stanzaregulator import YowStanzaRegulator from yowsup.layers.protocol_receipts import YowReceiptProtocolLayer from yowsup.layers.protocol_acks import YowAckProtocolLayer from yowsup.layers.logger import YowLoggerLayer from yowsup.layers.axolotl import YowAxolotlLayer from yowsup.layers.protocol_iq import YowIqProtocolLayer from yowsup.layers.protocol_calls import YowCallsProtocolLayer from yowsup.common import YowConstants from yowsup import env

CREDENTIALS = ("phone", "pws=") # replace with your phone and password

if name== "main": layers = ( EchoLayer, (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer, YowMediaProtocolLayer, YowIqProtocolLayer, YowCallsProtocolLayer), YowLoggerLayer, YowCoderLayer, YowCryptLayer, YowStanzaRegulator, YowNetworkLayer )

stack = YowStack(layers)
stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, CREDENTIALS)         #setting credentials

stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])    #whatsapp server address
stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)              
stack.setProp(YowCoderLayer.PROP_RESOURCE, env.CURRENT_ENV.getResource())          #info about us as WhatsApp client

stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))   #sending the connect signal

stack.loop() #this is the program mainloop

++++++++++++++++++++++++++++++++++++++++++++ and in file layer.py replace add or change these lines

@ProtocolEntityCallback("receipt") def onReceipt(self, entity): ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom())

    self.toLower(ack) 

paul218 avatar Jun 23 '15 06:06 paul218

Hi,

I've got these problems as well, but still a noob with python and yowsup. How can I get the debug xml?

gr

NCS80 avatar Jul 07 '15 09:07 NCS80

Add

logging.basicConfig(level=logging.DEBUG)

to your run.py (after the "from ... import ..." part)

Dl0tt avatar Jul 08 '15 12:07 Dl0tt

I still get the error in the initial post in this thread. I've added all the layers but still no solution. I'm running on raspbian.

Am I the only one still getting

DEBUG:yowsup.layers.logger.layer:rx:
<stream:error>
<ack>
</ack>
</stream:error>

DEBUG:yowsup.layers.network.layer:Disconnected, reason: Connection Closed
DEBUG:yowsup.layers.network.layer:Disconnected, reason: Connection Closed

error with all the layers in the code? Hope somebody can help or has any suggestions on other fixes?

also added

@ProtocolEntityCallback("receipt")
def onReceipt(self, entity):
    ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom())
    self.toLower(ack) 

but still no succes

thx

NCS80 avatar Jul 15 '15 20:07 NCS80

I have connection closed without any previous error:

DEBUG:yowsup.layers.protocol_iq.layer:ping queue size: 1 DEBUG:yowsup.layers.logger.layer:tx: <iq xmlns="w:p" type="get" id="36"> </iq>

DEBUG:yowsup.layers.logger.layer:rx: <iq type="result" from="[email protected]" id="36"> </iq>

DEBUG:yowsup.layers.network.layer:Disconnected, reason: Connection Closed DEBUG:yowsup.layers.network.layer:Disconnected, reason: Connection Closed DEBUG:yowsup.layers.protocol_iq.layer:stopping ping thread DEBUG:yowsup.layers.protocol_iq.layer:YowPingThread-1 - ping thread stopped

albpoz avatar Jul 22 '15 08:07 albpoz

Im getting the same error as well

DEBUG:yowsup.layers.logger.layer:rx:
<stream:error>
<ack>
</ack>
</stream:error>

DEBUG:yowsup.layers.network.layer:Disconnected, reason: Connection Closed
DEBUG:yowsup.layers.network.layer:Disconnected, reason: Connection Closed
DEBUG:yowsup.layers.protocol_iq.layer:stopping ping thread
DEBUG:yowsup.layers.protocol_iq.layer:YowPingThread-8 - ping thread stopped

layer.py Inside the YowInterfaceLayer

@ProtocolEntityCallback("receipt")
def onReceipt(self, entity):
        ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom())
        self.toLower(ack)

run.py

layers = (
        EchoLayer,
        (YowAuthenticationProtocolLayer,YowIqProtocolLayer,
         YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer,
         YowMediaProtocolLayer, YowCallsProtocolLayer),
        YowAxolotlLayer,
        YowLoggerLayer,
        YowCoderLayer,
        YowCryptLayer,
        YowStanzaRegulator,
        YowNetworkLayer
        )

sinanm89 avatar Aug 11 '15 17:08 sinanm89

Hi, I'm getting connection closed after a few pings, this happens both over yowsup-cli and my code. here's the log:

DEBUG:yowsup.layers.protocol_iq.layer:ping queue size: 1 DEBUG:yowsup.layers.logger.layer:tx:

DEBUG:yowsup.layers.logger.layer:rx:

DEBUG:yowsup.layers.protocol_iq.layer:ping queue size: 1 DEBUG:yowsup.layers.logger.layer:tx:

DEBUG:yowsup.layers.logger.layer:rx:

DEBUG:yowsup.layers.logger.layer:rx: stream:error /stream:error

DEBUG:yowsup.layers.network.layer:Disconnected, reason: Connection Closed DEBUG:yowsup.layers.protocol_iq.layer:stopping ping thread DEBUG:yowsup.layers.protocol_iq.layer:YowPingThread-1 - ping thread stopped

is there any known issue?

thanks a lot! ProHiki

ybarash avatar Nov 20 '15 09:11 ybarash

tried to get the pings more frequent, from 50 to 10 seconds. disconnected after 300 seconds like before..

ybarash avatar Nov 20 '15 15:11 ybarash

Hey Guys, I am having the same problem here! Is there any update to this issue?

DEBUG:yowsup.layers.logger.layer:rx: stream:error /stream:error

DEBUG:yowsup.layers.network.layer:Disconnected, reason: Connection Closed

rodrigocoliveira avatar Jan 15 '16 22:01 rodrigocoliveira

Sorry for pushing this up again - but is this a general error everyone is suffering or does anyone have a working Version at the moment?

Marcovus avatar Jan 29 '16 19:01 Marcovus

stream error for acks, send your acks

tgalal avatar Mar 22 '17 06:03 tgalal