Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Logical network change causes library not to be able to connect/reconnect. #490

Open
kdschlosser opened this issue Jul 17, 2018 · 5 comments

Comments

@kdschlosser
Copy link
Contributor

I am not sure if someone has come across this problem and knows of a solution.

Here is the scenario. It doesn't matter what server you are connected to.
What happens when connected and if a network change takes place. You connect to a VPN. now said VPN handles internet access while connected to it. I would expect a drop in connection to the server. but it never reconnects. I get a bad file descriptor error. Even if i close the connection and remake the client when connecting I get the same error.

@Neustradamus
Copy link

@kdschlosser: Have you tested with "master"?

Always same?

@kdschlosser
Copy link
Contributor Author

OK now I had to go and look. because I am confused here.

the master branch shows the last commits taking place 6 years ago. but the latest release shows 2017. so I am going to imagine that the released version is not gotten from the master branch. I do not know what branch the releases are generated from. But i did scroll back through the commit history for the develop branch back to before the last release was. there has been no code added to the develop branch since the latest release that addresses this problem. I am running the latest release and still have the issue.

There was another PR that I glanced at a few days ago when looking at the modified files there was something that caught my eye as to what can be causing the issue. I simply have not had the time to go back and check it yet.

@Neustradamus
Copy link

Neustradamus commented Apr 8, 2019

Have you logs for your problem?

Yes master is develop:

The last version is 1.3.3 but had a bug.

@kdschlosser
Copy link
Contributor Author

kdschlosser commented Apr 11, 2019

ok so here is a stack printout when the problem occurs,

To replicate the problem. While sleekxmpp is connected and running disable the network adapter that is being used. and then enable it again. you will see all kinds of file descriptor errors.

so after some poking about and getting a full stack printout. which is below. I isolated the issue and solved the problem.. only to have another one pop up in it's place. I am still trying to sort out the second problem now. which is it does a retry. connects and disconnects. it does this every 30 seconds or so it never fully connects. not sure why.

the problem is in the _ disconnect method of the XMLStream class. It tries to send a closing message to an already disconnected socket. and the reason the _disconnect gets called in the first place is because the connection dropped. so the threads never get closed down properly. and a reference to the old socket still exists. I do not remember where I saw it but there is code that checks to see if the socket is None or not and if it is None then it will create a new socket. and if it is not None then it will use the existing one. and I think this is what is boogering up the mechanics with the repeated file descriptor error. I am not sure 100%.

I did add a try except to the sending of the close packet to catch the exception in _disconnect. this allows the rest of the _disconnect code to run gracefully. But now I have that reconnect problem. and this problem produces no errors. I am working on it currently. But at least I have solved what has been an issue for a long long time (as in many years). I know there is an old issue about this already.

File "threading.pyc", line 774, in __bootstrap
File "threading.pyc", line 801, in __bootstrap_inner
File "threading.pyc", line 754, in run
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\xmlstream\xmlstream.py", line 1582, in _process
   self.event('socket_error', serr, direct=True)
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\xmlstream\xmlstream.py", line 1260, in event
   handler[0](out_data)
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\__init__.py", line 346, in _socket_callback
   traceback.print_stack()
File "threading.pyc", line 774, in __bootstrap
File "threading.pyc", line 801, in __bootstrap_inner
File "threading.pyc", line 754, in run
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\xmlstream\xmlstream.py", line 1600, in _process
  self.disconnect()
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\xmlstream\xmlstream.py", line 792, in disconnect
  args=(reconnect, wait, send_close))
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\thirdparty\statemachine.py", line 74, in transition
  func=func, args=args, kwargs=kwargs)
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\thirdparty\statemachine.py", line 119, in transition_any
  return_val = func(*args,**kwargs) if func is not None else True
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\xmlstream\xmlstream.py", line 815, in _disconnect
  self.send_raw(self.stream_footer, now=True)
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\xmlstream\xmlstream.py", line 1428, in send_raw
  self.event('socket_error', serr, direct=True)
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\xmlstream\xmlstream.py", line 1260, in event
  handler[0](out_data)
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\__init__.py", line 346, in _socket_callback
  traceback.print_stack()
File "threading.pyc", line 774, in __bootstrap
File "threading.pyc", line 801, in __bootstrap_inner
File "threading.pyc", line 754, in run
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\xmlstream\xmlstream.py", line 1600, in _process
  self.disconnect()
 File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\xmlstream\xmlstream.py", line 792, in disconnect
  args=(reconnect, wait, send_close))
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\thirdparty\statemachine.py", line 74, in transition
  func=func, args=args, kwargs=kwargs)
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\thirdparty\statemachine.py", line 119, in transition_any
  return_val = func(*args,**kwargs) if func is not None else True
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\xmlstream\xmlstream.py", line 837, in _disconnect
  self.event('socket_error', serr, direct=True)
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\sleekxmpp\xmlstream\xmlstream.py", line 1260, in event
  handler[0](out_data)
File "C:\ProgramData\EventGhost\plugins\XMPPPlus\__init__.py", line 346, in _socket_callback
  traceback.print_stack()

@kdschlosser
Copy link
Contributor Author

and that is using the latest code in the develop branch as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants