gpt4 book ai didi

android - Android 应用程序 Meteor 后端的 OpeningHandshakeException

转载 作者:行者123 更新时间:2023-11-29 01:10:47 25 4
gpt4 key购买 nike

我刚刚使用简单的 meteor create hellometeor 命令学习并实现了我的第一个 Meteor 应用程序,然后使用了 ngrok使 localhost:3000 端口生效。

然后我用了delight-im/Android-DDP根据以下代码连接到直接 ws url 的库:

    // create a new instance, where mMeteor is a global var.
mMeteor = new Meteor(this, "ws://180a3c0e.ngrok.io", new InMemoryDatabase()); // "ws://180a3c0e.ngrok.io" is the temp. url after tunneling `localhost:3000`

// register the callback that will handle events and receive messages
mMeteor.addCallback(this); // as the activity implements MeteorCallback

// establish the connection
mMeteor.connect();

但是每次我尝试运行这段代码时,我都会收到以下错误,对于像我这样的新手,在过去的 6 小时内,我没有找到任何建议或直接的解决方案谷歌搜索和阅读:

W/System.err: java.lang.Exception: com.neovisionaries.ws.client.OpeningHandshakeException: The status code of the opening handshake response is not '101 Switching Protocols'. The status line is: HTTP/1.0 502 Bad Gateway
W/System.err: at im.delight.android.ddp.Meteor$1.onError(Meteor.java:195)
W/System.err: at com.neovisionaries.ws.client.ListenerManager.callOnError(ListenerManager.java:432)
W/System.err: at com.neovisionaries.ws.client.ConnectThread.handleError(ConnectThread.java:50)
W/System.err: at com.neovisionaries.ws.client.ConnectThread.run(ConnectThread.java:41)
W/System.err: Caused by: com.neovisionaries.ws.client.OpeningHandshakeException: The status code of the opening handshake response is not '101 Switching Protocols'. The status line is: HTTP/1.0 502 Bad Gateway
W/System.err: at com.neovisionaries.ws.client.HandshakeReader.validateStatusLine(HandshakeReader.java:232)
W/System.err: at com.neovisionaries.ws.client.HandshakeReader.readHandshake(HandshakeReader.java:54)
W/System.err: at com.neovisionaries.ws.client.WebSocket.readHandshake(WebSocket.java:3113)
W/System.err: at com.neovisionaries.ws.client.WebSocket.shakeHands(WebSocket.java:2992)
W/System.err: at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2034)
W/System.err: at com.neovisionaries.ws.client.ConnectThread.run(ConnectThread.java:37)

可能是我在 Meteor 服务器端遗漏了一个非常常见的事情,因为除了启动项目之外,我没有在其中编写一行代码。
请在这方面启发我。< br/>TIA。

最佳答案

我应该因为不知道 Meteor 在 ws://.../websocket url 有它的 websocket 连接而被钉在十字架上。

我刚刚在上一个 URL 的末尾添加了 /websocket,一切正常。

关于android - Android 应用程序 Meteor 后端的 OpeningHandshakeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43304888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com