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

Timed out while calling get_updates() #20

Closed
ismoil-nosr opened this issue Sep 17, 2018 · 17 comments
Closed

Timed out while calling get_updates() #20

ismoil-nosr opened this issue Sep 17, 2018 · 17 comments
Assignees
Labels
question A question about how the program works.

Comments

@ismoil-nosr
Copy link

$ sudo python3 -OO core.py

greed-bot is now starting!
Timed out while calling get_updates(), retrying in 1 secs...
Exception in thread Worker 411164928:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/default.py", line 509, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: users

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/home/ubuntu/tlgrm_shop/worker.py", line 64, in run
self.user = self.session.query(db.User).filter(db.User.user_id == self.chat.id).one_or_none()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 2917, in one_or_none
ret = list(self)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 2988, in iter
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3011, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 948, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
compiled_sql, distilled_params
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
exc_info
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/util/compat.py", line 265, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/util/compat.py", line 248, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/default.py", line 509, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: users [SQL: 'SELECT users.user_id AS users_user_id, users.first_name AS users_first_name, users.last_name AS users_last_name, users.username AS users_username, users.credit AS users_credit \nFROM users \nWHERE users.user_id = ?'] [parameters: (411164928,)] (Background on this error at: http://sqlalche.me/e/e3q8)

Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...

@ismoil-nosr
Copy link
Author

This is the error that I'm getting while trying to start the bot

@Steffo99 Steffo99 self-assigned this Sep 17, 2018
@Steffo99 Steffo99 added the question A question about how the program works. label Sep 17, 2018
@Steffo99
Copy link
Owner

This error means that the database engine did not found the required tables.
Have you run db.py at least once before starting the core, as explained in the README?

@ismoil-nosr
Copy link
Author

No. I didn't know about that. Could you tell me where is it placed?

@Steffo99
Copy link
Owner

Whoops, just noticed a typo in the readme, will fix as soon as I get to a computer.
You're supposed to run python3.6 -OO database.py before starting core.py.

@ismoil-nosr
Copy link
Author

OK, I did it, but now get this one:

greed-bot is now starting!
Exception in thread Worker 411164928:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/default.py", line 509, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: users

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/home/ubuntu/greed/worker.py", line 64, in run
self.user = self.session.query(db.User).filter(db.User.user_id == self.chat.id).one_or_none()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 2917, in one_or_none
ret = list(self)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 2988, in iter
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3011, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 948, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
compiled_sql, distilled_params
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
exc_info
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/util/compat.py", line 265, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/util/compat.py", line 248, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/default.py", line 509, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: users [SQL: 'SELECT users.user_id AS users_user_id, users.first_name AS users_first_name, users.last_name AS users_last_name, users.username AS users_username, users.credit AS users_credit \nFROM users \nWHERE users.user_id = ?'] [parameters: (411164928,)] (Background on this error at: http://sqlalche.me/e/e3q8)

^CTraceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 395, in _make_request
httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "core.py", line 123, in
main()
File "core.py", line 41, in main
timeout=int(configloader.config["Telegram"]["long_polling_timeout"]))
File "/home/ubuntu/greed/utils.py", line 120, in result_func
return func(*args, **kwargs)
File "/home/ubuntu/greed/utils.py", line 180, in get_updates
return self.bot.get_updates(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/telegram/bot.py", line 65, in decorator
result = func(self, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/telegram/bot.py", line 1975, in get_updates
result = self._request.post(url, data, timeout=float(read_latency) + float(timeout))
File "/usr/local/lib/python3.6/dist-packages/telegram/utils/request.py", line 309, in post
headers={'Content-Type': 'application/json'})
File "/usr/local/lib/python3.6/dist-packages/telegram/utils/request.py", line 203, in _request_wrapper
resp = self._con_pool.request(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/telegram/vendor/ptb_urllib3/urllib3/request.py", line 70, in request
**urlopen_kw)
File "/usr/local/lib/python3.6/dist-packages/telegram/vendor/ptb_urllib3/urllib3/request.py", line 148, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "/usr/local/lib/python3.6/dist-packages/telegram/vendor/ptb_urllib3/urllib3/poolmanager.py", line 244, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/local/lib/python3.6/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 617, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 398, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.6/ssl.py", line 1009, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.6/ssl.py", line 871, in read
return self._sslobj.read(len, buffer)
File "/usr/lib/python3.6/ssl.py", line 631, in read
v = self._sslobj.read(len, buffer)
KeyboardInterrupt

@ismoil-nosr
Copy link
Author

Now i did changes to config.ini file and make url of sqlite like this:
engine = sqlite:////home/user/greed/db.sqlite
And it starts to work! Congrats!

@ismoil-nosr
Copy link
Author

Bot works, But still getting errors in server side:

Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
Timed out while calling get_updates(), retrying in 1 secs...
^CTraceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 395, in _make_request
httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "core.py", line 123, in
main()
File "core.py", line 41, in main
timeout=int(configloader.config["Telegram"]["long_polling_timeout"]))
File "/home/ubuntu/greed/utils.py", line 120, in result_func
return func(*args, **kwargs)
File "/home/ubuntu/greed/utils.py", line 180, in get_updates
return self.bot.get_updates(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/telegram/bot.py", line 65, in decorator
result = func(self, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/telegram/bot.py", line 1975, in get_updates
result = self._request.post(url, data, timeout=float(read_latency) + float(timeout))
File "/usr/local/lib/python3.6/dist-packages/telegram/utils/request.py", line 309, in post
headers={'Content-Type': 'application/json'})
File "/usr/local/lib/python3.6/dist-packages/telegram/utils/request.py", line 203, in _request_wrapper
resp = self._con_pool.request(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/telegram/vendor/ptb_urllib3/urllib3/request.py", line 70, in request
**urlopen_kw)
File "/usr/local/lib/python3.6/dist-packages/telegram/vendor/ptb_urllib3/urllib3/request.py", line 148, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "/usr/local/lib/python3.6/dist-packages/telegram/vendor/ptb_urllib3/urllib3/poolmanager.py", line 244, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/local/lib/python3.6/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 617, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 398, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.6/ssl.py", line 1009, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.6/ssl.py", line 871, in read
return self._sslobj.read(len, buffer)
File "/usr/lib/python3.6/ssl.py", line 631, in read
v = self._sslobj.read(len, buffer)
KeyboardInterrupt
^CException ignored in: <module 'threading' from '/usr/lib/python3.6/threading.py'>
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 1294, in _shutdown
t.join()
File "/usr/lib/python3.6/threading.py", line 1056, in join
self._wait_for_tstate_lock()
File "/usr/lib/python3.6/threading.py", line 1072, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt

Is it normal?

@Steffo99
Copy link
Owner

It depends.
If you're getting 1 every second, it means the bot is somehow unable to connect to Telegram.
If you're getting them less often (like 1 per minute) it is just a notification that the Telegram servers are being slower than usual and the bot may answer with a small delay.

Either way, it's not a problem on your end but on the Telegram side.

@ismoil-nosr
Copy link
Author

ismoil-nosr commented Sep 17, 2018

Got it. Another problem I'm getting if I use my modified strings.py file with Russian keywords, after command
/start bot sends me text in conversation_after_start = "text...." . Bot reacts only for command /start but there no other commands, keyboards displayed. Is it bug with Russian keywords or I missed/deleted any tags/code while editing?

In server side getting this errors:

Network error while calling send_message(), retrying in 5 secs...
Network error while calling send_message(), retrying in 5 secs...
Timed out while calling send_message(), retrying in 1 secs...
Network error while calling send_message(), retrying in 5 secs...
Network error while calling send_message(), retrying in 5 secs...
^CTraceback (most recent call last):
File "core.py", line 123, in
main()
File "core.py", line 58, in main
old_worker.stop("request")
File "/home/ubuntu/greed/worker.py", line 118, in stop
self.join()
File "/usr/lib/python3.6/threading.py", line 1056, in join
self._wait_for_tstate_lock()
File "/usr/lib/python3.6/threading.py", line 1072, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt
^CException ignored in: <module 'threading' from '/usr/lib/python3.6/threading.py'>
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 1294, in _shutdown
t.join()
File "/usr/lib/python3.6/threading.py", line 1056, in join
self._wait_for_tstate_lock()
File "/usr/lib/python3.6/threading.py", line 1072, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt

@Steffo99
Copy link
Owner

That's... unusual.
Do you get any errors in the console?

@ismoil-nosr
Copy link
Author

That's... unusual.
Do you get any errors in the console?

updated comment

@Steffo99
Copy link
Owner

Steffo99 commented Sep 18, 2018

I'm wondering what those Network Errors are.
It shouldn't be because of the cyrillic strings...
I'll try adding more detailed logging tomorrow right now, so we can find the source of the errors.

@Steffo99
Copy link
Owner

Try to update to c2bed58 and run the bot without the -OO command line option (debug mode).

python3.6 core.py

@Steffo99 Steffo99 added the bug Something that doesn't work as expected. label Sep 18, 2018
@ismoil-nosr
Copy link
Author

Well, I did as you said. After I ran bot with cyrillic strings, I got this errors:

# python3.6 core.py
greed-bot is now starting!
Timed out while calling get_updates(), retrying in 1 secs...
Network error while calling send_message(), retrying in 5 secs...
Full error: Can't parse entities: unclosed end tag at byte offset 31
Timed out while calling get_updates(), retrying in 1 secs...
Network error while calling send_message(), retrying in 5 secs...
Full error: Can't parse entities: unclosed end tag at byte offset 31
Network error while calling send_message(), retrying in 5 secs...
Full error: Can't parse entities: unclosed end tag at byte offset 31
Network error while calling send_message(), retrying in 5 secs...
Full error: Can't parse entities: unclosed end tag at byte offset 31
^CTraceback (most recent call last):
File "core.py", line 123, in
main()
File "core.py", line 58, in main
old_worker.stop("request")
File "/home/ubuntu/greed/worker.py", line 118, in stop
self.join()
File "/usr/lib/python3.6/threading.py", line 1056, in join
self._wait_for_tstate_lock()
File "/usr/lib/python3.6/threading.py", line 1072, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt
Network error while calling send_message(), retrying in 5 secs...
Full error: Can't parse entities: unclosed end tag at byte offset 31
^CException ignored in: <module 'threading' from '/usr/lib/python3.6/threading.py'>
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 1294, in _shutdown
t.join()
File "/usr/lib/python3.6/threading.py", line 1056, in join
self._wait_for_tstate_lock()
File "/usr/lib/python3.6/threading.py", line 1072, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt

And also, when I run bot, it reacts only one time to command /start but not else after.

@Steffo99
Copy link
Owner

You have to replace < and > in your strings with &lt; and &gt; respectively, because Telegram reads the html tags <b>bold</b>, <i>italic</i> and <code>moonospace</code> for formatting.

@Steffo99 Steffo99 removed the bug Something that doesn't work as expected. label Sep 19, 2018
@ismoil-nosr
Copy link
Author

YES! IT WORKS!
Thanks a lot for your help!!!
You're GREAT!

@Steffo99
Copy link
Owner

Thanks! If you want, let me know how the bot works, how do you want to use it and if you encounter any more bugs, so I can fix them! 😄

I'm closing this issue, since your problem was solved 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question about how the program works.
Projects
None yet
Development

No branches or pull requests

2 participants