首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >telegram api -不适用于线程

telegram api -不适用于线程
EN

Stack Overflow用户
提问于 2015-02-15 13:00:40
回答 1查看 613关注 0票数 0

我使用telegram-api库。当我使用以下main方法运行app时:

代码语言:javascript
复制
    public static void main(String[] args) throws IOException {
        Application app = new Application();
        app.disableLogging();
        app.createApi();
        app.login();
        app.workLoop();
    }

它工作得很好。但是当我这样做的时候:

代码语言:javascript
复制
    //Somewhere else
    public void testRun() throws Exception {
        System.out.println("run");
        Application app = new Application();
        app.main(null);
        Thread.sleep(10*60*1000);
    }

它抛出以下异常:

代码语言:javascript
复制
Exception in thread "Scheduller#988181144" java.lang.NullPointerException
    at org.telegram.tl.StreamingUtils.writeTLString(StreamingUtils.java:125)
    at org.telegram.api.requests.TLRequestAuthSignIn.serializeBody(Unknown Source)
    at org.telegram.tl.TLObject.serialize(TLObject.java:46)
    at org.telegram.tl.StreamingUtils.writeTLObject(StreamingUtils.java:192)
    at org.telegram.tl.StreamingUtils.writeTLMethod(StreamingUtils.java:203)
    at org.telegram.api.requests.TLRequestInvokeWithLayer11.serializeBody(Unknown Source)
    at org.telegram.tl.TLObject.serialize(TLObject.java:46)
    at org.telegram.tl.TLObject.serialize(TLObject.java:34)
    at org.telegram.mtproto.schedule.Scheduller.actualPackages(Scheduller.java:388)
    at org.telegram.mtproto.schedule.Scheduller.doSchedule(Scheduller.java:406)
    at org.telegram.mtproto.MTProto$SchedullerThread.run(MTProto.java:704)

我使用telegram-bot项目中的代码。有什么问题吗?谢谢。

EN

回答 1

Stack Overflow用户

发布于 2016-12-20 01:03:26

你可能还没有设置TLRequestAuthSignIn的字段之一(见第三行) phoneNumber,phoneCodeHash和/或phoneCode。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28523147

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档