telegram-history-dump
telegram-history-dump copied to clipboard
connection refused !
I start telegram-cli by bin/telegram-cli --json -P 9009
then type ctrl + c
to halt the window then type ruby ./telegram-history-dump.rb
. then I get the following error :
:~/tg# ruby ./telegram-history-dump.rb
I, [2016-08-22T22:26:18.023648 #5512] INFO -- : Attaching to telegram-cli control socket at localhost:9009
./telegram-history-dump.rb:26:in `initialize': Connection refused - connect(2) for "localhost" port 9009 (Errno::ECONNREFUSED)
from ./telegram-history-dump.rb:26:in `open'
from ./telegram-history-dump.rb:26:in `connect_socket'
from ./telegram-history-dump.rb:276:in `<main>'
What should I do now?
You shouldn't terminate telegram-cli but keep it running until the backup is done. So basically you need two terminals / terminal tabs in your situation.
ok, I used screen on ssh and this issue have solved . After running the script, I got some telegram chats then the following message
I, [2016-08-23T08:13:25.320190 #12410] INFO -- : Backing up 0 dialogs: (none)
I, [2016-08-23T08:13:25.320393 #12410] INFO -- : Formatting messages
W, [2016-08-23T08:13:25.320566 #12410] WARN -- : Config options "copy_media" or "download_media.document|photo|..." not enabled. HTML dump might be missing images and/or files.
I, [2016-08-23T08:13:25.321965 #12410] INFO -- : HTML export finished, see: output/formatted/html/index.html
I, [2016-08-23T08:13:25.322168 #12410] INFO -- : Finished
So the output file is empty. this is my config file with html as output format
backup_users: [
'my telegram username without @ or something else'
]
# Array of group dialogs to backup
backup_groups: [
null
]
# Array of supergroup dialogs to backup
backup_supergroups: [
null
]
backup_channels: [
null
]
Is there something wrong ?
backup_users is not meant for putting your own username, but rather the user dialog names you want to backup. You can just leave it empty ([]
) to backup dialogs with all of your contacts. If you do the same for backup_groups (remove the null
) it will backup all group dialogs as well.
Thanks ! I entered the user dialog name and it started. but there is a problem. when it gets to a broken link, it returns error and start from the beginning, there should be a way to pass the broken links. can you give me a solution how to edit the ruby script for solving this problem now?
I don't understand what you mean by "when it gets to a broken link", can you elaborate? Can you show a log and/or example output?
I get this error
E, [2016-08-23T22:29:53.485753 #25969] ERROR -- : Failed to download media file: no implicit conversion of nil into String
E, [2016-08-23T22:29:53.487990 #25969] ERROR -- : Failed to download media file: Broken pipe
I, [2016-08-23T22:29:53.550530 #25969] INFO -- : Dumping "......" (range 73601-74000)
telegram-history-dump.rb:35:in `write': Broken pipe (Errno::EPIPE)
from telegram-history-dump.rb:35:in `puts'
from telegram-history-dump.rb:35:in `exec_tg_command'
from telegram-history-dump.rb:68:in `block in dump_dialog'
from /usr/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
from /usr/lib/ruby/2.3.0/timeout.rb:33:in `block in catch'
from /usr/lib/ruby/2.3.0/timeout.rb:33:in `catch'
from /usr/lib/ruby/2.3.0/timeout.rb:33:in `catch'
from /usr/lib/ruby/2.3.0/timeout.rb:106:in `timeout'
from telegram-history-dump.rb:67:in `dump_dialog'
from telegram-history-dump.rb:323:in `block in <main>'
from telegram-history-dump.rb:319:in `each'
from telegram-history-dump.rb:319:in `each_with_index'
from telegram-history-dump.rb:319:in `<main>'
I don't know exactly what it means but I think it can't download a file because "404 not found" error or something, by the way I'm not sure about this.
I, [2016-08-24T16:05:10.859844 #14821] INFO -- : Attaching to telegram-cli control socket at localhost:9009
telegram-history-dump.rb:26:in `initialize': Connection refused - connect(2) for "localhost" port 9009 (Errno::ECONNREFUSED)
from telegram-history-dump.rb:26:in `open'
from telegram-history-dump.rb:26:in `connect_socket'
from telegram-history-dump.rb:276:in `<main>'
Encountered the same problem. But using screen or multiply terminals doesn't help. Any advice's?
This is not supposed to happen, perhaps something changed in telegram-cli or the Telegram api. I'll take a look at it as soon as I can.
@uyouu how are you running telegram-cli?
At first, im running telegram-cli via screen:
screen bin/telegram-cli -k tg-server.pub --json -P 9009
Then, im hiding the telegram-cli screen (Ctrl+A+D) and try to execute your script:
ruby telegram-history-dump.rb
And after all i get an error message, which i have posted before.
@tvdstaaij Thanks, I can't check that message because I should scroll up to reach range of 73601-74000 !! If you know an easier way how to do this, tell me and I will check that messages to see what is it all about I think it's better to know what exactly that message is. I'll be waiting for your update about this ...
@uyouu at first type this bin/telegram-cli -k --json -P 9009
and check if telegram is running correctly, you should see messages in json format then detach the screen then run a new screen by typing screen
then try ruby ./telegram-history-dump.rb
@saeeds255 that is exactly what i did.
@uyouu that should work, I had the same problem and had been solved. I think you did something wrong in these steps
@uyouu That should indeed work. I personally prefer tmux over screen these days, you could try that as an alternative:
- Install tmux and start a new session by running
tmux
- Start telegram-cli with the right arguments
- Open a new tab with Ctrl-B C (meaning control+B, release, then press C)
- Start telegram-history-dump.rb
You can switch between the tabs with Ctrl-B N.
@saeeds255 As for your issue, the problem is that telegram-cli can be rather unstable, especially when media downloading is involved, and simply crashes in some situations. Unfortunately my script can't prevent telegram-cli from crashing. I'm currently playing with some ideas for a v3 of this script that would automatically run telegram-cli in the background. Then if it crashes, it could also be restarted and proceed from the next chunk. For now I recommend disabling media downloads, just the message data does not crash the latest version of telegram-cli as far as I know.
telegram-cli -k --json -P 9009
does not return json over 9009...
I had to run ./telegram-cli -d --json -P 9009 --json
for some reason...
Hi, one year later and experiencing the same connection refused issue with the telegram-history-dump command.
I installed tmux thinking that it could be a multiplexer issue and no dice. Is there anything I need to examine in the config.yaml file for further evaluation?
I have set maximum dialogues to 10000; chunk_size is set to 10; chunk_delay is 3.0. Not sure if rate limiting could be an issue-although this throttling is very slow.
`I, [2017-09-26T20:52:04.923064 #22683] INFO -- : Attaching to telegram-cli control socket at localhost:9009
telegram-history-dump.rb:36:in `initialize': Connection refused - connect(2) for "localhost" port 9009 (Errno::ECONNREFUSED)
from telegram-history-dump.rb:36:in `open'
from telegram-history-dump.rb:36:in `connect_socket'
from telegram-history-dump.rb:320:in `<main>'`
I'm not sure what else to do at this point?