Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

local vs internet ws server #34

Closed
dmtrlbdv1 opened this issue May 6, 2015 · 5 comments
Closed

local vs internet ws server #34

dmtrlbdv1 opened this issue May 6, 2015 · 5 comments

Comments

@dmtrlbdv1
Copy link
Contributor

I am trying to open connection to the server and now I have an issue with it. If it local started crossbar.io server - I am able to connect to it, but I am can't connect to any internet server ( for example wss://demo.crossbar.io/ws ). In this case only cycled disconnect-connection states. What I am doing incorrect ?

try {
// Create a builder and configure the client
WampClientBuilder builder = new WampClientBuilder();

// builder.withUri("ws://192.168.1.39:8282/ws")
builder.withUri("wss://demo.crossbar.io/ws")
.withRealm("realm1")
.withInfiniteReconnects()
.withReconnectInterval(5, TimeUnit.SECONDS);
// Create a client through the builder. This will not immediatly start
// a connection attempt
client = builder.build();

        client.statusChanged().subscribe(new Action1<WampClient.Status>() {
            private Subscription procSubscription;

            public void call(WampClient.Status t1) {
                Log.d("info", "Session status changed to " + t1);

                if (t1 == WampClient.Status.Connected) {
                    Log.d("info", "Connected");
                }
            }
        });

        client.open();

    } catch (WampError e) {
        // Catch exceptions that will be thrown in case of invalid configuration
        e.printStackTrace();
        return;
    }
@dmtrlbdv1
Copy link
Contributor Author

I am sorry - I forget to add... I try to connect from the android (device and emulator), if it important

@Matthias247
Copy link
Owner

Your code is correct. Does your android app have the internet permission?

@dmtrlbdv1
Copy link
Contributor Author

Yes, internet permission is set ( as I said my localhost is available form my app ). May be I do not set some dependencies in gradle ? ( maven repository have set in another gradle file ) Or may be I need make some steps to connect to wss server ? I tried withSslContext(SslContext.newClientContext(InsecureTrustManagerFactory.INSTANCE)) - but nothing changed.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '21.1.2'

    defaultConfig {
        applicationId "...."
        minSdkVersion 10
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    android {
        packagingOptions {
            exclude 'META-INF/io.netty.versions.properties'
            exclude 'META-INF/INDEX.LIST'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.0'
    compile 'com.android.support:support-v4:22.1.0'
    compile 'ws.wamp.jawampa:jawampa:0.2.0'
}

@Matthias247
Copy link
Owner

Sorry, can't help you regarding Android configuration as I have no experience with that. In #21 there was a discussion about the correct settings for Proguard, maybe you have a problem with that. @jrogers also build an example for android, maybe this helps: https://github.com/jrogers/AndroidWampExample

If you want to debug why the connection fails you could put breakpoints in the associated Netty Channel Handlers for the connection (e.g. in WampClientWebsocketHandler, WebSocketClientProtocolHandler, WebSocketClientProtocolHandshakeHandler, WebSocketClientHandshaker08). Sorry - currently don't have time to investigate that deeper myself.

@dmtrlbdv1
Copy link
Contributor Author

Thank you. I found nexus 7 (5.0) and tried to start my app on it - all working! I do not understand why samsung galaxy s not allow me to connect. I hope it is just certificates issue or something and my server will be working without problems.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants