0

I am trying to connect to a running meteor application using a Java DDPClient.

I am using this Java ddp client.

I just added these couple of lines to the Android activity:

DDPClient mDdp = new DDPClient(sMeteorIp, sMeteorPort);
mDdp.connect();

but I got and exception from the DDPClient::handleError(Exception ex):

failed to connect to localhost/127.0.0.1 (port 3000): connect failed:
ECONNREFUSED (Connection refused)

The meteor application is up and running (version is 0.8.3, the latest for windows).
The meteor application is here: https://github.com/stefanopiovesn/ProteinTracker
The java ddp client is here: https://github.com/stefanopiovesn/DDPClient
A working ddp javascript client is here: https://github.com/stefanopiovesn/AsteroidSample
Any idea why this error happens?

4

2 に答える 2

0

主な理由は、'localhost' を入力すると、アプリケーションの URL に関連するためです。サーバーの URL ではありません。

この場合、サーバーの URL は、PC が指定したポートでサーバーを実行しているため、PC の raw IP です。

Android コードの localhost は、サーバー (別名 PC) の localhost ではなく、Android アプリケーションを参照します。

なぜ例外がスローされるのですか? -サーバー(または指定したポートでデータをリッスンしているAndroidアプリケーション上のもの)がないため-コードは、Androidアプリケーションから独自のAndroidアプリケーションに接続しようとしていることを意味するため

:)

于 2015-03-12T04:27:27.063 に答える
0

私はこの問題を抱えていました。使用する優れたツールは ngrok です! http://ngrok.com

パブリック Web サーバー経由でトラフィックをローカル マシンにトンネリングできます。外部デバイスでのすべての開発に使用しています

于 2015-03-04T02:07:13.513 に答える