Giter VIP home page Giter VIP logo

Comments (14)

 avatar commented on July 2, 2024 2

Since version 0.1.20 you can provide your own axios instance with custom options:

import axios from 'axios'
import * as https from 'https'
import { ag, Airgram, TYPES } from 'airgram'
import MtpNetwork from 'airgram/base/MtpNetwork'

const airgram = new Airgram({ /* options */ })

airgram.bind<MtpNetwork>(TYPES.MtpNetwork).to(MtpNetwork).onActivation((context, network) => {
  const httpsAgent = new https.Agent()
  network.axios = axios.create({ httpsAgent })
  return network
})

You can try this recipe to create socks5 https agent.

from airgram.

 avatar commented on July 2, 2024 1

Try to import MtpNetwork this way:

const MtpNetwork = require('airgram/base/MtpNetwork').default

from airgram.

amir3code avatar amir3code commented on July 2, 2024

Actually I did all of that but it did not work. I'll try to stick to using torify (it mostly works) and VPN for now until airgram gets a built-in support for socks proxy.
Thanks.

from airgram.

 avatar commented on July 2, 2024

Check whether it works with the 0.1.21 version or not. If not, please provide some more information about errors.

from airgram.

qwertvasilii avatar qwertvasilii commented on July 2, 2024

@airgram it throws error
Error: Missing required @Injectable annotation in: Anonymous function: [object Object].

from airgram.

k0t0fey avatar k0t0fey commented on July 2, 2024

I also confirm this feature does not work.
airgram version: 0.1.21
My code:

    const airgram = new Airgram({id: conf.api_id, hash: conf.api_hash});

    // Proxy
    airgram.bind(TYPES.MtpNetwork).to(MtpNetwork).onActivation((context, network) => {
        network.axios = axios.create({
            httpsAgent: new https.Agent(),
        });
        return network;
    });

After default timeout throw error:

Error: Request timeout exceeded.
    at Timeout._onTimeout (tg\node_modules\airgram\base\Client.js:280:89)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)

from airgram.

 avatar commented on July 2, 2024

@qwertvasilii, can you share your code?

@k0t0fey, I've just checked your code. It works for me. If you are in Russia or in some other banned area, try to use proxy as described here.

from airgram.

k0t0fey avatar k0t0fey commented on July 2, 2024

Yep, I'am from Russia, but I use vpn on my router, so all banned services working for me.
For example, if I disable part with network.axios and request any tg-method, then it work fine:

const dialogs = await airgram.client.messages.getDialogs({
                // flags: 0,
                limit: 100,
                offset_date: last_date,
                offset_id: 0,
                offset_peer: { _: 'inputPeerEmpty' }
            });

dialogs contains all actual data:
screen

from airgram.

 avatar commented on July 2, 2024

@k0t0fey, can you upload verbose log with and without network settings? Don't forget to remove sensitive data

from airgram.

k0t0fey avatar k0t0fey commented on July 2, 2024

verbose_log_without_network_stg.log
verbose_log_with_network_stg.log

the same error as described by @qwertvasilii
airgram error 15:58:17.254 [MtpClient][1] sendScheduledRequest() "Missing required @injectable annotation in: Anonymous function: [object Object]." +3ms

from airgram.

k0t0fey avatar k0t0fey commented on July 2, 2024

Any ideas how to solve this problem?

from airgram.

 avatar commented on July 2, 2024

I can't reproduce this error. Please can you clone this repo (test-network branch) and check whether the example works for you or not.

from airgram.

k0t0fey avatar k0t0fey commented on July 2, 2024

Very likely the problem occurs with a projects based in a pure js.

from airgram.

k0t0fey avatar k0t0fey commented on July 2, 2024

Thx, now all works! =)

from airgram.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.