Skip to content
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

Erreur avec TLSMemoryBIOProtocol #36

Open
N3bTcx opened this issue Mar 15, 2017 · 19 comments
Open

Erreur avec TLSMemoryBIOProtocol #36

N3bTcx opened this issue Mar 15, 2017 · 19 comments

Comments

@N3bTcx
Copy link

N3bTcx commented Mar 15, 2017

J'ai updaté mon os récement et gazouilleur ne reboot plus. Je renté une install from scratch mais sans résultat. Je sèche.

2017-03-15 21:29:31 [IRC/#gazouilleur] Left.
2017-03-15 21:29:31 [IRC] Connection lost because: [Failure instance: Traceback: <class 'OpenSSL.SSL.Error'>: [('SSL routines', 'SSL3_GET_RECORD', 'wrong version number')]
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/internet/posixbase.py:614:_doReadOrWrite
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/internet/tcp.py:209:doRead
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/internet/tcp.py:215:_dataReceived
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/protocols/tls.py:415:dataReceived
        --- <exception caught here> ---
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/protocols/tls.py:554:_write
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/OpenSSL/SSL.py:1271:send
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/OpenSSL/SSL.py:1191:_raise_ssl_error
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/OpenSSL/_util.py:48:exception_from_error_queue
        ].
2017-03-15 21:29:31 [IRCBot (TLSMemoryBIOProtocol),client] <twisted.internet.tcp.Connector instance at 0x3c73b00> will retry in 39 seconds
2017-03-15 21:29:31 [IRCBot (TLSMemoryBIOProtocol),client] Stopping factory <__builtin__.IRCBotFactory instance at 0x3c73e60>
@N3bTcx
Copy link
Author

N3bTcx commented Mar 15, 2017

Message plus complet :


2017-03-15 22:17:13 [-] Starting factory <__builtin__.IRCBotFactory instance at 0x3da1e18>
2017-03-15 22:17:13 [�[32;1mtwitter�[0m] �[33;1mSet Twitter shortened urls length for !count to 23 characters.�[0m
2017-03-15 22:17:13 [�[32;1mIRC�[0m] �[36;1mConnection made�[0m
2017-03-15 22:17:14 [�[32;1mIRC�[0m/�[34;1m#chan1�[0m] �[35;1mLeft.�[0m
2017-03-15 22:17:14 [�[32;1mIRC�[0m/�[34;1m#chan2�[0m] �[35;1mLeft.�[0m
2017-03-15 22:17:14 [�[32;1mIRC�[0m/�[34;1m#chan3�[0m] �[35;1mLeft.�[0m
2017-03-15 22:17:14 [�[32;1mIRC�[0m/�[34;1m#chan4�[0m] �[35;1mLeft.�[0m
2017-03-15 22:17:14 [�[32;1mIRC�[0m/�[34;1m#gazouilleur�[0m] �[35;1mLeft.�[0m
2017-03-15 22:17:14 [�[32;1mIRC�[0m] �[35;1mConnection lost because: [Failure instance: Traceback: <class 'OpenSSL.SSL.Error'>: [('SSL routines', 'SSL3_GET_RECORD', 'wrong version number')]
	/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/internet/posixbase.py:614:_doReadOrWrite
	/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/internet/tcp.py:209:doRead
	/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/internet/tcp.py:215:_dataReceived
	/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/protocols/tls.py:415:dataReceived
	--- <exception caught here> ---
	/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/protocols/tls.py:554:_write
	/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/OpenSSL/SSL.py:1256:send
	/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/OpenSSL/SSL.py:1174:_raise_ssl_error
	/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/OpenSSL/_util.py:48:exception_from_error_queue
	].�[0m
2017-03-15 22:17:14 [IRCBot (TLSMemoryBIOProtocol),client] <twisted.internet.tcp.Connector instance at 0x3da1ab8> will retry in 440 seconds
2017-03-15 22:17:14 [IRCBot (TLSMemoryBIOProtocol),client] Stopping factory <__builtin__.IRCBotFactory instance at 0x3da1e18>
2017-03-15 22:17:15 [-] Received SIGTERM, shutting down.
2017-03-15 22:17:15 [-] Main loop terminated.
2017-03-15 22:17:15 [-] Server Shut Down.
2017-03-15 22:17:29 [-] Log opened.
2017-03-15 22:17:29 [-] twistd 15.1.0 (/home/n3b/.virtualenvs/gazouilleur/bin/python 2.7.3) starting up.
2017-03-15 22:17:29 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2017-03-15 22:17:29 [-] Starting factory <__builtin__.IRCBotFactory instance at 0x3925e18>

@N3bTcx
Copy link
Author

N3bTcx commented Mar 16, 2017

J'ai poussé la version de twisted à 17.1

$ pip install -r requirements.txt
............
Requirement already satisfied (use --upgrade to upgrade): ndg-httpsclient>=0.4.0 in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from -r requirements.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): lxml in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from -r requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): feedparser in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from -r requirements.txt (line 4))
Requirement already satisfied (use --upgrade to upgrade): service-identity in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from -r requirements.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): zope.interface in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from -r requirements.txt (line 6))
Requirement already satisfied (use --upgrade to upgrade): twisted>=17.1.0 in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from -r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): stevedore in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from -r requirements.txt (line 8))
Requirement already satisfied (use --upgrade to upgrade): virtualenvwrapper in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from -r requirements.txt (line 9))
Requirement already satisfied (use --upgrade to upgrade): pymongo==3.0.3 in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from -r requirements.txt (line 12))
Requirement already satisfied (use --upgrade to upgrade): txmongo==15.1.0 in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from -r requirements.txt (line 13))
Requirement already satisfied (use --upgrade to upgrade): twitter>=1.17 in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from -r requirements.txt (line 16))
Requirement already satisfied (use --upgrade to upgrade): pypump==0.5.0 in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from -r requirements.txt (line 19))
Requirement already satisfied (use --upgrade to upgrade): PyOpenSSL in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from ndg-httpsclient>=0.4.0->-r requirements.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): setuptools in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from zope.interface->-r requirements.txt (line 6))
Requirement already satisfied (use --upgrade to upgrade): constantly>=15.1 in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from twisted>=17.1.0->-r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): incremental>=16.10.1 in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from twisted>=17.1.0->-r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): Automat>=0.3.0 in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from twisted>=17.1.0->-r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from virtualenvwrapper->-r requirements.txt (line 9))
Requirement already satisfied (use --upgrade to upgrade): virtualenv-clone in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from virtualenvwrapper->-r requirements.txt (line 9))
Requirement already satisfied (use --upgrade to upgrade): requests-oauthlib>=0.3.0 in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from pypump==0.5.0->-r requirements.txt (line 19))
Requirement already satisfied (use --upgrade to upgrade): requests>=1.2.0 in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from pypump==0.5.0->-r requirements.txt (line 19))
Requirement already satisfied (use --upgrade to upgrade): python-dateutil>=2.1 in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages (from pypump==0.5.0->-r requirements.txt (line 19))
Cleaning up...

Toujours le même soucis

J'ai vérifié pyOpenSSL aussi

$ pip install PyOpenSSL --upgrade
Requirement already up-to-date: PyOpenSSL in /home/n3b/.virtualenvs/gazouilleur/lib/python2.7/site-packages
Cleaning up...

Mais pas de changement

@RouxRC
Copy link
Owner

RouxRC commented Mar 16, 2017

Autre piste : essaie d'appliquer le patch proposé dans #34

@potager
Copy link

potager commented Aug 17, 2017

Ça passe par ici si je spécifie la version du protocole via ssl_options :

ssl_options = ssl.optionsForClientTLS(hostname=config.HOST.decode("utf-8"), extraCertificateOptions={ 'method': SSL.TLSv1_METHOD })

@RouxRC
Copy link
Owner

RouxRC commented Aug 17, 2017

@potager Je ne connais pas bien les protocoles classiques des serveurs IRC, tu penses que le spécifier globalement aurait du sens ?
@N3bTcx si tu as l'occase de tester, dis nous!

@N3bTcx
Copy link
Author

N3bTcx commented May 10, 2018

@potager Merci, je test de suite.

Dsl j'avais jamais vu ton message mais j'ai moins eu l'erreur récement.

@N3bTcx
Copy link
Author

N3bTcx commented May 10, 2018

Erreur instantanée

2018-05-10 13:00:10 [IRC] Connection lost because: [Failure instance: Traceback: <class 'OpenSSL.SSL.Error'>: [('SSL routines', 'ssl3_get_record', 'wrong version number')]
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/internet/posixbase.py:614:_doReadOrWrite
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/internet/tcp.py:209:doRead
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/internet/tcp.py:215:_dataReceived
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/protocols/tls.py:422:dataReceived
        --- <exception caught here> ---
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/protocols/tls.py:360:_flushReceiveBIO
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/OpenSSL/SSL.py:1684:recv
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/OpenSSL/SSL.py:1546:_raise_ssl_error
        /home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/OpenSSL/_util.py:54:exception_from_error_queue
        ].
2018-05-10 13:00:10 [IRCBot (TLSMemoryBIOProtocol),client] <twisted.internet.tcp.Connector instance at 0x7f2a77b73320> will retry in 152 seconds
2018-05-10 13:00:10 [IRCBot (TLSMemoryBIOProtocol),client] Stopping factory <__builtin__.IRCBotFactory instance at 0x7f2a77b73488>

@RouxRC
Copy link
Owner

RouxRC commented May 11, 2018

Essaie avec TLSv3 ou V2_3peut-être, cela doit dépendre du serveur auquel tu te connectes j'imagine

@N3bTcx
Copy link
Author

N3bTcx commented May 14, 2018

J'ai essayé

OpenSSL.SSL.TLSv1_METHOD
OpenSSL.SSL.TLSv1_1_METHOD
OpenSSL.SSL.TLSv1_2_METHOD

mais l'erreur réaparait après 7-8h

Si je tente SSLv3

$ gazouilleur/bin/gazouilleur restart                                                                                                                             [7:16:27]
Stopping Gazouilleur instance bauer...
....lock.bauer.pid is missing, searching process...
...the bot does not seem like running.

Starting Gazouilleur instance bauer...
Unhandled Error
Traceback (most recent call last):
  File "/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/application/app.py", line 642, in run
    runApp(config)
  File "/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/scripts/twistd.py", line 23, in runApp
    _SomeApplicationRunner(config).run()
  File "/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/application/app.py", line 376, in run
    self.application = self.createOrGetApplication()
  File "/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/application/app.py", line 441, in createOrGetApplication
    application = getApplication(self.config, passphrase)
--- <exception caught here> ---
  File "/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/application/app.py", line 452, in getApplication
    application = service.loadApplication(filename, style, passphrase)
  File "/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/application/service.py", line 403, in loadApplication
    application = sob.loadValueFromFile(filename, 'application', passphrase)
  File "/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/persisted/sob.py", line 210, in loadValueFromFile
    exec fileObj in d, d
  File "/home/n3b/gazouilleur/gazouilleur/bot.py", line 1654, in <module>
    ssl_options = ssl.optionsForClientTLS(hostname=config.HOST.decode("utf-8"), extraCertificateOptions={ 'method': SSL.SSLv3_METHOD })
  File "/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/internet/_sslverify.py", line 1231, in optionsForClientTLS
    **extraCertificateOptions
  File "/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/python/deprecate.py", line 611, in wrapped
    return wrappee(*args, **kwargs)
  File "/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/internet/_sslverify.py", line 1452, in __init__
    _expandCipherString(u'ALL', self.method, self._options)
  File "/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/twisted/internet/_sslverify.py", line 1663, in _expandCipherString
    ctx = SSL.Context(method)
  File "/home/n3b/.virtualenvs/gazouilleur/local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 710, in __init__
    raise ValueError("No such protocol")
exceptions.ValueError: No such protocol

Failed to load application: No such protocol

@N3bTcx
Copy link
Author

N3bTcx commented May 14, 2018

J'ai cette erreur après quelques heures:

2018-05-14 07:14:46 [IRC] Connection lost because: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other
side was lost in a non-clean fashion: Connection lost.
        ].
2018-05-14 07:14:46 [IRCBot (TLSMemoryBIOProtocol),client] <twisted.internet.tcp.Connector instance at 0x7f27c8687320> will retry in 2 seconds
2018-05-14 07:14:46 [IRCBot (TLSMemoryBIOProtocol),client] Stopping factory <__builtin__.IRCBotFactory instance at 0x7f27c8687488>

@RouxRC
Copy link
Owner

RouxRC commented May 18, 2018

Ça ça peut arriver quand il y a des problèmes de connectivité, ce n'est pas forcément lié et il se reconnecte tout seul normalement après non?

@N3bTcx
Copy link
Author

N3bTcx commented May 25, 2018

@RouxRC malheureusement non. #36 (comment) c'est fatale. Le bot ne se reconnecte pas.

@N3bTcx
Copy link
Author

N3bTcx commented May 26, 2018

Voilà exactement ce que j'ai.
capture d ecran 2018-05-26 a 09 27 28

@N3bTcx
Copy link
Author

N3bTcx commented Jun 12, 2018

Petit up. Malheureusement je suis toujours bloqué. Dois je mettre à python et implémenter un "retry" si j'ai cet échec?

@RouxRC
Copy link
Owner

RouxRC commented Jun 12, 2018

Je ne sais plus trop quoi te proposer malheureusement :(
Je ne comprends pas pourquoi il se coupe alors qu'il annonce lui-même qu'il va réessayer de se connecter, et c'est une feature intégrée de la lib twisted donc à tweaker c pas évident :/
J'ai pas mieux qu'une solution dégueu du genre une cron toutes les minutes pour un script qui checke que le process tourne et le relance sinon...

@N3bTcx
Copy link
Author

N3bTcx commented Jun 20, 2018

Le soucis c'est que le process tourne toujours.

$ ps aux | grep gaz
n3b       8863  0.0  0.2  13372  2408 pts/2    S+   Jun19   0:00 /bin/bash gazouilleur/bin/gazouilleur restart

alors que les logs de gazouilleur affichent:

2018-06-20 01:00:18 [IRC] Connection lost because: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
        ].
2018-06-20 01:00:18 [IRCBot (TLSMemoryBIOProtocol),client] <twisted.internet.tcp.Connector instance at 0x7f543559b320> will retry in 2 seconds
2018-06-20 01:00:18 [IRCBot (TLSMemoryBIOProtocol),client] Stopping factory <__builtin__.IRCBotFactory instance at 0x7f543559b488>
2018-06-20 01:00:18 [-] Main loop terminated.
2018-06-20 01:00:18 [-] Server Shut Down.

Mmmmh.. par contre le pid! Je vais regarder la prochaine fois.

@boogheta
Copy link
Collaborator

C'est vraiment étrange, je ne sais vraiment pas quelle direction te conseiller :/

@N3bTcx
Copy link
Author

N3bTcx commented Jun 25, 2018

Bon. J'ai fait un script très naif

$ cat reboot_gazouilleur.sh
PIDFILE="$HOME/gazouilleur/.lock.bauer.pid"

if [ -e "${PIDFILE}" ]; then
  echo "Already running."
  exit 99
fi

echo "not running"
gazouilleur/bin/gazouilleur start

ça tourne depuis 4 jours et mon gazouilleur n'est jamais tombé une seule fois.. Je comprends rien... mais ça marche. Merci pour votre aide. Je pense qu'on fermer l'issue pour le moment.

@boogheta
Copy link
Collaborator

Laule, c'est une fois les mesures prises que le problème ne survient plus :D

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

No branches or pull requests

4 participants