Search code examples
androidmeteorddpjava-websocket

Connection state is closed when sending authorization request using DDP protocol


I am using kenyee's Android DDP Client library to connect my Android application to a server running Meteor-JS.

I've modified his Meteor.js Parties ANdroid Demo. I attempt to login with existing user credentials and get Login Error. Please, help!

I create DDPStateSingleton with the following settings:

String meteorServer = "http://<sandbox_name>.nitrousbox.com";
Integer meteorPort = 3000;
mInstance = new MyDDPState(context, meteorServer, meteorPort);

(Meteor-js server is running in nitrous.io sandbox) And then I perform a user login attempt:

MyDDPState.getInstance().login(mEmail, mPassword);

But I get WebsocketNotConnectedException (it is throwed from org.java_websocket.WebSocketImpl#send(String)) so my login request ends with error message

"Unknown websocket error (exception in callback?)"

Singleton state during exception:

mConnState = Closed
mMeteorServerAddress = ws://http://<sandbox_name>.nitrousbox.com:3000/websocket

It is strange, I see that connection is closed although connectIfNeeded() was called before.

UPD:
The first received async message from DDP server is of type error.
The second received async message is of type closed.


Solution

  • It was java.nio.channels.UnresolvedAddressException. Hostname should be specified without a protocol:

    String meteorServer = "<sandbox_name>.nitrousbox.com";