首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >延迟库HttpResponseMessage错误

延迟库HttpResponseMessage错误
EN

Stack Overflow用户
提问于 2013-05-29 19:40:25
回答 1查看 436关注 0票数 0

我正在尝试使用ttorrent库来创建android应用程序。我有点问题。

05-29 23:07:23.388: E/AndroidRuntime(3681):致命异常:bt-宣告(..393337) 05-29 23:07:23.388: E/AndroidRuntime(3681):java.lang.NullPointerException 05-29 23:07:23.388: E/AndroidRuntime(3681):at com.turn.ttorrent.common.protocol.http.HTTPAnnounceResponseMessage.parse(HTTPAnnounceResponseMessage.java:105) 05-29 23:07:23.388: E/AndroidRuntime(3681):at com.turn.ttorrent.common.protocol.http.HTTPTrackerMessage.parse(HTTPTrackerMessage.java:51) 05-29 23:07:23.388: E/AndroidRuntime(3681):at com.turn.ttorrent.client.announce.HTTPTrackerClient.announce(HTTPTrackerClient.java:124) 05-29 23:07:23.388: E/AndroidRuntime(3681):at com.turn.ttorrent.client.announce.Announce.run(Announce.java:224) 05-29 23:07:23.388: E/AndroidRuntime(3681):at java.lang.Thread.run(Thread.java:856)

代码语言:javascript
复制
public static HTTPAnnounceResponseMessage parse(ByteBuffer data)
    throws IOException, MessageValidationException {
    BEValue decoded = BDecoder.bdecode(data);
    if (decoded == null) {
        throw new MessageValidationException(
            "Could not decode tracker message (not B-encoded?)!");
    }

    Map<String, BEValue> params = decoded.getMap();

    try {
        List<Peer> peers;

        try {
            // First attempt to decode a compact response, since we asked
            // for it.
            peers = toPeerList(params.get("peers").getBytes());
        } catch (InvalidBEncodingException ibee) {
            // Fall back to peer list, non-compact response, in case the
            // tracker did not support compact responses.
            peers = toPeerList(params.get("peers").getList());
        }

        return new HTTPAnnounceResponseMessage(data,
            params.get("interval").getInt(),
            params.get("complete").getInt(),
            params.get("incomplete").getInt(),
            peers);
    } catch (InvalidBEncodingException ibee) {
        throw new MessageValidationException("Invalid response " +
            "from tracker!", ibee);
    } catch (UnknownHostException uhe) {
        throw new MessageValidationException("Invalid peer " +
            "in tracker response!", uhe);
    }

没有键这样的“间隔”或“完整”或“倾斜”是对线。有两个键“对等”和“最小间隔”。

只要我在调用Client方法之后得到它,它就会请求跟踪器提供一些信息,然后尝试解析这些信息。这就是错误所在。

那么,问题是为什么会这样呢?是图书馆出了差错还是我出了什么问题?

EN

回答 1

Stack Overflow用户

发布于 2013-05-29 21:59:51

问题到底是什么?

请编辑您的问题并添加更多细节。

理想情况下包括一个斯考斯

向您的问题中添加一个指向显示此错误的洪流文件的链接。你是怎么建夜店的?

确认您所看到的错误发生在从Android运行时,而不是在普通Java中。

您可以使用git从github获取ttorrent代码,也可以单击github项目上的按钮下载zip。

ttorrent使用maven。如果手动获取依赖项,则可能无法获得正确的版本。您应该将代码作为maven项目导入Eclipse。Eclipse ->文件-> ...Import -> Maven ->现有Maven项目

在导航窗格中。查找ttorrent项目并右击选择Run -> Maven Build .在“包”中键入目标并单击"Run“。

我从ttorrent示例客户机开始,并将路径添加到已知的好Ubuntu 13.04洪流文件以及要保存到的目录中。

我在调试器中运行了代码,ttorrent正确地运行了。它开始下载Ubuntu,没有引发异常或打印错误消息。

在您列出的行中,我看到params映射有四个条目(“间隔”、“完整”、“对等”、“不完整”)。

下面是我使用的客户端代码:

代码语言:javascript
复制
public class ClientTest
{

    public static void main(String[] args) throws NoSuchAlgorithmException
    {    
        try {
            SharedTorrent fromFile =
            SharedTorrent.fromFile(
            new File("j:/ubuntu-13.04-desktop-amd64.iso.torrent"),
            new File("j:/td"));
            Client client =
                new Client(InetAddress.getLocalHost(), fromFile);
            client.download();
            client.waitForCompletion();
        } catch (UnknownHostException ex) {
            Logger.getLogger(ClientTest.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(ClientTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

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

https://stackoverflow.com/questions/16822484

复制
相关文章

相似问题

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