Title: Most likely the client time has to be synchronized · Issue #62 · hydrogram/hydrogram · GitHub
Open Graph Title: Most likely the client time has to be synchronized · Issue #62 · hydrogram/hydrogram
X Title: Most likely the client time has to be synchronized · Issue #62 · hydrogram/hydrogram
Description: Checklist I am sure the error is coming from Hydrogram's code and not elsewhere I have searched in the issue tracker for similar bug reports, including closed ones I ran pip3 install -U https://github.com/hydrogram/hydrogram/archive/dev....
Open Graph Description: Checklist I am sure the error is coming from Hydrogram's code and not elsewhere I have searched in the issue tracker for similar bug reports, including closed ones I ran pip3 install -U https://git...
X Description: Checklist I am sure the error is coming from Hydrogram's code and not elsewhere I have searched in the issue tracker for similar bug reports, including closed ones I ran pip3 install -U https:/...
Opengraph URL: https://github.com/hydrogram/hydrogram/issues/62
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Most likely the client time has to be synchronized","articleBody":"### Checklist\n\n- [x] I am sure the error is coming from Hydrogram's code and not elsewhere\n- [x] I have searched in the issue tracker for similar bug reports, including closed ones\n- [x] I ran `pip3 install -U https://github.com/hydrogram/hydrogram/archive/dev.zip` and reproduced the issue using the latest development version\n\n### Description\n\nThe Hydrogram bot does not connect to Telegram in any way and does not report any error.Unless you enable logging in debug mode, it's possible to find the error. Otherwise, Hydrogram does not report the error, and the bot is not started.\n\nSolution:\nsudo date -s \"$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')\"\n\n### Steps to reproduce\n\nTo reproduce the error, simply have your server's time out of sync with Telegram. When trying to connect using Hydrogram, no error is reported, leaving the user unable to understand why it doesn't connect.\n\n### Code example\n\n```python\nimport os\nimport logging\nfrom hydrogram import Client, filters\n\n# Configurar logs detalhados\nlogging.basicConfig(\n level=logging.DEBUG,\n format=\"%(asctime)s - %(name)s - %(levelname)s - %(message)s\",\n handlers=[\n logging.StreamHandler(), # Exibe logs no console\n logging.FileHandler(\"debug.log\", encoding=\"utf-8\") # Salva logs em arquivo\n ]\n)\n\n\n# Configurando as variáveis de ambiente diretamente (substitua pelos seus valores reais)\nAPI_ID = os.getenv(\"API_ID\", 123456) # Substitua pelo seu API_ID\nAPI_HASH = os.getenv(\"API_HASH\", \"abc123def456\") # Substitua pelo seu API_HASH\nBOT_TOKEN = os.getenv(\"BOT_TOKEN\", \"seu_bot_token_aqui\") # Substitua pelo seu BOT_TOKEN\n\nlogging.debug(\"Configurando o cliente...\")\ntry:\n app = Client(\n name=\"my_bot\",\n api_id=API_ID,\n api_hash=API_HASH,\n bot_token=BOT_TOKEN,\n )\n logging.info(\"Cliente configurado com sucesso.\")\nexcept Exception as e:\n logging.critical(f\"Erro ao configurar o cliente: {e}\")\n raise\n\n# Função simples para responder mensagens privadas\n@app.on_message(filters.private)\nasync def hello(client, message):\n logging.debug(f\"Recebeu uma mensagem: {message.text}\")\n await message.reply(\"Hello from Hydrogram!\")\n\n# Executar o cliente\nlogging.debug(\"Iniciando o cliente...\")\ntry:\n app.run()\nexcept Exception as e:\n logging.critical(f\"Erro crítico ao executar o cliente: {e}\")\n```\n\n### Logs\n\n```shell\n2025-04-05 11:22:34,653 - hydrogram.session.session - INFO - Discarding packet: The msg_id belongs to over 30 seconds in the future. Most likely the client time has to be synchronized.\n\n2025-04-05 11:22:34,653 - hydrogram.session.session - INFO - NetworkTask stopped\n\n2025-04-05 11:22:34,653 - hydrogram.connection.connection - INFO - Disconnected\n```","author":{"url":"https://github.com/matheuszbb","@type":"Person","name":"matheuszbb"},"datePublished":"2025-04-05T15:14:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/62/hydrogram/issues/62"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ab525c8b-4c12-248e-bd76-7718a5a1be66 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DF32:24C625:2BA3CB:3A288B:69730623 |
| html-safe-nonce | 7e60199046e1511f0087605665535045215ffa655a27a8374e6a66454596bedf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjMyOjI0QzYyNToyQkEzQ0I6M0EyODhCOjY5NzMwNjIzIiwidmlzaXRvcl9pZCI6IjQ2ODk5NTYwNjUzODQ3OTM2MzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0cb7539670e9328c58c3a4abcc6f0cc53d36f7133c20dfec72017e80c87a1341 |
| hovercard-subject-tag | issue:2974275539 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/hydrogram/hydrogram/62/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6789faaee0b5cec37379a2947e8df0a077b38162be3948ae457a93d6085019fa/hydrogram/hydrogram/issues/62 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6789faaee0b5cec37379a2947e8df0a077b38162be3948ae457a93d6085019fa/hydrogram/hydrogram/issues/62 |
| og:image:alt | Checklist I am sure the error is coming from Hydrogram's code and not elsewhere I have searched in the issue tracker for similar bug reports, including closed ones I ran pip3 install -U https://git... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | matheuszbb |
| hostname | github.com |
| expected-hostname | github.com |
| None | 44ab3188c1dcfe3be0f9c3feca2e04e14fb79f120939ce2395e4f15ab96ec1d4 |
| turbo-cache-control | no-preview |
| go-import | github.com/hydrogram/hydrogram git https://github.com/hydrogram/hydrogram.git |
| octolytics-dimension-user_id | 153278131 |
| octolytics-dimension-user_login | hydrogram |
| octolytics-dimension-repository_id | 711555265 |
| octolytics-dimension-repository_nwo | hydrogram/hydrogram |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 711555265 |
| octolytics-dimension-repository_network_root_nwo | hydrogram/hydrogram |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a5e2b48bd1260476599758f5d253b5d24092ab84 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width