Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

479
Views
nodeJS - RequestError de rechazo no controlado: Error: el socket cuelga

Tengo este código que funciona bien para la primera parte. Estoy tratando de enviar un video al usuario después de que seleccione qué video desea ver. El problema es que no puedo lograrlo porque siempre recibo este error Solicitud de error Unhandled rejection RequestError: Error: socket hang up .

 #!/usr/bin/env node const TelegramBot = require('node-telegram-bot-api'); const TorrentSearchApi = require('torrent-search-api'); const TorrentStream = require('torrent-stream'); const bot = new TelegramBot('5xxxx', {polling: true}); const providers = TorrentSearchApi.getProviders(); //console.log(providers); TorrentSearchApi.enablePublicProviders(); let magnetLinks = [] let response = 'Here are your search results: \n'; let engine; let stream; // Matches "/echo [whatever]" bot.onText(/\/search (.+)/, async (msg, match) => { // 'msg' is the received Message from Telegram // 'match' is the result of executing the regexp above on the text content // of the message console.log(match[1]); TorrentSearchApi.search(match[1], 'All', 10).then( (results) => { results.forEach( (item, index) => { if( item.seeds > 1 ){ response += `${index}) ${item.title}\n`; magnetLinks.push(item.magnet); } }); bot.sendMessage(msg.chat.id, response).then( (message) => { bot.sendMessage(msg.chat.id, 'Use the /stream command followed by the number of the torrent file you want to play'); }); }); }); bot.onText(/\/stream (.+)/, async (msg, match) => { console.log(magnetLinks[match[1]]); engine = TorrentStream(magnetLinks[match[1]]); engine.on('ready', () => { engine.files.forEach( (file) => { console.log('filename:', file.name); stream = file.createReadStream(); console.log(stream); // stream is readable stream to containing the file content bot.sendVideo(msg.chat.id, stream); }); }); });

¿Cómo puedo resolver el problema y dejar que el bot de Telegram envíe el archivo de video al usuario? ¿Es posible transmitir un archivo de video con un bot de Telegram?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!