LaggKing
LaggKing

Reputation: 53

Can't get SignalA on android to connect to SignalR backend

I'm trying to use SignalA (https://github.com/erizet/SignalA) for a small android application.

My SignalR instance is up and looks as follows:

namespace SignalRPersistent
{
    public class ChatConnection : PersistentConnection
    {
        protected override Task OnConnected(IRequest request, string connectionId)
        {
            return Connection.Send(connectionId, "Welcome!");
        }

        protected override Task OnReceived(IRequest request, string connectionId, string data)
        {
            return Connection.Broadcast(data);
        }
    }
}

my Startup.cs looks like this:

namespace SignalRPersistent
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR<ChatConnection>("/echo");
        }
    }
}

on the Android side,the relevent code i have is:

String url = "http://10.0.2.2:45223/echo/";
com.zsoft.signala.Connection con = new com.zsoft.signala.Connection(url, this, new LongPollingTransport()) {

    @Override
    public void OnError(Exception exception) {
        Toast.makeText(MyActivity.this, "On error: " + exception.getMessage(), Toast.LENGTH_LONG).show();
    }

    @Override
    public void OnMessage(String message) {
        Toast.makeText(MyActivity.this, "Message: " + message, Toast.LENGTH_LONG).show();
    }

    @Override
    public void OnStateChanged(StateBase oldState, StateBase newState) {

        Toast.makeText(MyActivity.this, "oldState: " + oldState.getState() + " newState: " + newState.getState(), Toast.LENGTH_LONG).show();
    }
};

It seems to see to locate it just fine, but shortly after Disconnects. the state changed from Connecting to Disconnected.

what am I missing here?

Upvotes: 1

Views: 243

Answers (1)

LaggKing
LaggKing

Reputation: 53

Looks like the problem was with the applicationhost.config file on my IIS.

I had to change

binding protocol="http" bindingInformation="*:45223:localhost" 

to:

binding protocol="http" bindingInformation="*:45223:*"

Upvotes: 1

Related Questions