Christopher Johnson
Christopher Johnson

Reputation: 2629

SignalR android SDK only works on WiFi connection

To be clear, this question is referencing the Android SDK for SignalR...not SignalR running in a browser on an android device.

For some reason, I can not establish a connection to the server when using my wireless data network (3g). I'm able to connect to my server via web services and receive a JSON string of data, but SignalR will not connect.

SignalRFuture<Void> awaitConnection = connection.start();
            try {
                awaitConnection.get(5000, TimeUnit.MILLISECONDS);
            } catch (InterruptedException e) {
                // Handle ...
            } catch (ExecutionException e) {
                // Handle ...
            } catch (TimeoutException e) {
                Log.d(TAGSR,"it timed out");
                e.printStackTrace();
            }

this hits the timeout exception always when I'm NOT on WiFi...even if I bump it up to a minute +. What's weird is that as soon as it times out, the other aforementioned data loads instantly. If I turn my WiFi on my phone, this connects no problem at all.

Using the same SignalR connection with my browser, I'm able to connect via 3g with no problems at all...it's only the Android SDK version that pukes unless it's on WiFi. Is there some built in mechanism to the SDK that requires a certain connection speed? If so, is there a way to override that value? My 3g ain't a ferrari, but it's fast enough to work over the web version, and work fine at that....

any ideas? TIA

Upvotes: 4

Views: 717

Answers (1)

Christopher Johnson
Christopher Johnson

Reputation: 2629

no idea why, but it appears that it's the transport selection that's causing a failure on 3g.

when I comment out one or the other (serversentevents or longpolling) in AutomaticTransport, it works fine...

private void initialize(Logger logger) {
    mTransports = new ArrayList<ClientTransport>();
    mTransports.add(new ServerSentEventsTransport(logger));
    //mTransports.add(new LongPollingTransport(logger));
}

Upvotes: 2

Related Questions