Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Events are not being listened from android devices #36

Closed
amanaman118 opened this issue Oct 12, 2016 · 24 comments
Closed

Events are not being listened from android devices #36

amanaman118 opened this issue Oct 12, 2016 · 24 comments

Comments

@amanaman118
Copy link

I have done setup of deepstream on my local mac machine. its working fine
used js client for creating master to emit event whenever device gets connected to deepstream with listen and its working fine

const DeepstreamClient = require( '../src/client' )
const ds = DeepstreamClient( 'localhost:6021' )
ds.login()

ds.event.listen('57fb28b9ef70ca0d6238df2d/commands', function (eventName, isSubscribed, response) {
    console.log('eventName:',eventName, ' , isSubscribed:', isSubscribed, ' ,response:', response)
    if (isSubscribed) {
        ds.event.emit('57fb28b9ef70ca0d6238df2d/commands', '#Command1')
    }
    else {

    }
})

ds.event.subscribe("57fb28b9ef70ca0d6238df2d/loggedIn", function (deviceId){
    console.log("device loggedIn : ", deviceId)
})

And below is what i have used in java to connect with deepstream

try {
                    dp = new DeepstreamClient("192.168.1.134:6021", new DeepstreamRuntimeErrorHandler() {
                        @Override
                        public void onException(Topic topic, Event event, String errorMessage) {
                            System.out.println("exception : " + errorMessage);
                        }
                    });

                    dp.login();
                    dp.event.emit("57fb28b9ef70ca0d6238df2d/loggedIn", "oneplus2");

                    dp.event.subscribe("57fb28b9ef70ca0d6238df2d/commands", new EventListener() {
                        @Override
                        public void onEvent(String eventName, Object... args) {
                            System.out.println("event called : " + eventName);
                        }
                    });

                } catch (Exception e) {
                    e.printStackTrace();
                }

Its able to connect to deep-stream, as i can see logs coming over deep-stream terminal for Incoming connection
But master which is working already is not able to listen to above android incoming device also emitting manual event is not reaching to device.

Whereas, trying same stuff from another terminal window of my mac machine its working fine.

const DeepstreamClient = require( '../src/client' )
const ds = DeepstreamClient( 'localhost:6021' )
ds.login()
ds.event.emit("57fb28b9ef70ca0d6238df2d/loggedIn", "terminal");

ds.event.subscribe("57fb28b9ef70ca0d6238df2d/commands", function (data){
    console.log("command received : ", data)
})

console.log("subscribed to 57fb28b9ef70ca0d6238df2d/commands")

Need help on why android device is not able to listen to any event happening from master.
Anything i am missing.

@yasserf
Copy link
Contributor

yasserf commented Oct 12, 2016

hey @amanaman118

The java master is currently using websockets as part of our move from engine.io to uws.

Can you use this version:

0b6d304

@amanaman118
Copy link
Author

Thnx @yasserf I have downloaded zipped content of commit id (0b6d304) shared by you.

But couldn't find any difference in codebase of above commit id and latest code pulled from java master branch.

As i have compared all code file with latest one. Their is no change in the source code of deepstream to connect back with tcp connectivity.

@yasserf
Copy link
Contributor

yasserf commented Oct 12, 2016

Ah, sorry I assumed you were connecting via websocket which makes connectivity not work against master deepstream.io server

Can you tell me if https://github.com/deepstreamIO/deepstream.io-client-java/tree/master/src/testapplication/java/io/deepstream/testapp works? That covers all the usual subscribe/publish aspects.

@amanaman118
Copy link
Author

Sorry to say, i am getting exception with what above sample code has.
Its with url exception.

java.net.URISyntaxException: URL provided is not correct: ws://192.168.1.134:6020/deepstream
10-12 17:29:42.565 com.aman.ds W/System.err: at io.deepstream.EndpointTCP.(EndpointTCP.java:36)
10-12 17:29:42.565 com.aman.ds W/System.err: at io.deepstream.Connection.createEndpoint(Connection.java:308)
10-12 17:29:42.565 com.aman.ds W/System.err: at io.deepstream.Connection.(Connection.java:54)
10-12 17:29:42.565 com.aman.ds W/System.err: at io.deepstream.DeepstreamClient.(DeepstreamClient.java:79)
10-12 17:29:42.565 com.aman.ds W/System.err: at io.deepstream.DeepstreamClient.(DeepstreamClient.java:67)
10-12 17:29:42.565 com.aman.ds W/System.err: at com.semusi.sdk.MainActivity$1.doInBackground(MainActivity.java:251)
10-12 17:29:42.565 com.aman.ds W/System.err: at com.semusi.sdk.MainActivity$1.doInBackground(MainActivity.java:241)

@yasserf
Copy link
Contributor

yasserf commented Oct 12, 2016

yeah thats the problem due to it using pure websockets rather than TCP, you should use the latest release tag. I do apologise, this is a pretty big transition so relying on master isn't the best approach for the next few days.

@amanaman118
Copy link
Author

Hi, @yasserf I have tried 0.8 tag release as well. But same issue persist when tried from android device.
Deepstream terminal is showing incoming connection.
Do i need to use any older version of deepstream as well. Because i have used 0.8 tag release of java/android client.

Below is what comming over in my terminal window

INFO | logger ready
INFO | deepstream version: 1.1.1
INFO | configuration file loaded from conf/config.yml
INFO | library directory set to: /Aman/SafariDwn/deepstream.io-mac-1.1.1/lib
INFO | messageConnector ready
INFO | storage ready
INFO | cache ready
INFO | authenticationHandler ready: none
INFO | permissionHandler ready: valve permissions loaded from /Aman/SafariDwn/deepstream.io-mac-1.1.1/conf/permissions.yml
INFO | Using uws websocket server
CLUSTER_JOIN | iu7ax5gd-1wlevc7gn9a84
INFO | Listening for tcp connections on 0.0.0.0:6021
INFO | Listening for browser connections on 0.0.0.0:6020
INFO | Deepstream started
CLUSTER_LEAVE | iu7ax5gd-1wlevc7gn9a84
CLUSTER_JOIN | iu7ax5gd-1wlevc7gn9a84
INCOMING_CONNECTION | from 192.168.1.134:51287 via tcp

@amanaman118
Copy link
Author

Also i have tried running below app
https://github.com/deepstreamIO/ds-demo-pizza-tracker

but below is what i am getting as an issue

Process: example.deepstream.io.pizzatracker, PID: 11566
io.deepstream.DeepstreamException: CONNECTION_ERROR: Can't connect! Deepstream server unreachable on 52.29.229.244:6021
at io.deepstream.DeepstreamClientAbstract.onError(DeepstreamClientAbstract.java:55)
at io.deepstream.Connection$1.run(Connection.java:163)
at java.util.Timer$TimerImpl.run(Timer.java:284)

Later i thought that server at '52.29.229.244' mite not be working.
So i update ip to my local machine ip, i have got it running. But master running on terminal is not able to track the device.

@yasserf
Copy link
Contributor

yasserf commented Oct 13, 2016

Hey Aman,

I'm about to merge the websockets branches into master, and will then test out the java/android example and let you know the outcome!

@amanaman118
Copy link
Author

Oky, but after doing restart of deepstream 1.1.1 along with 0.5 client.
Things are working as expected.
Master running on terminal in my mac machine is able to listen to client being connected from android devices.

@yasserf
Copy link
Contributor

yasserf commented Oct 13, 2016

Great! Will try and normalize everything by end of today so all masters are using websockets.

@amanaman118
Copy link
Author

Thnx @yasserf
Is their any way i can do load test to confirm whether things are working perfectly or not.
For me to be production ready.

@yasserf
Copy link
Contributor

yasserf commented Oct 13, 2016

Hey aman,

We load tested the server in different scenarios and are currently working on a test harness for simultaneous connections. We currently managed to get up to 1million concurrent connections using websockets due to its lower footprints than engine.io.

Can you specify what kind of load test you are interested in?

@amanaman118
Copy link
Author

Hello Yaseer,

Thnx for sharing information over test harness.
I have gone over to link shared https://deepstream.io/info/performance/four-billion-messages-per-hour/ it had covered what so ever i am looking for.

@yasserf
Copy link
Contributor

yasserf commented Oct 14, 2016

Perfect!

@amanaman118
Copy link
Author

Hi, Seen your commits with websocket changes. Can i start using it or should i wait for stable release.
As i can see their is a build-failure tag marked for repo on master branch.

Also is their any possibility to get 0.5 version codebase, i have checked in tags/branches couldn't find it.

@yasserf
Copy link
Contributor

yasserf commented Oct 17, 2016

You can start using it against deepstream master, ill be doing a alpha release soon with artifacts

@amanaman118
Copy link
Author

amanaman118 commented Oct 17, 2016

Hi, I have tested the latest master branch.
Upon login function of java client deepstream. Its stuck as it not getting listened on server end.

As i said in starting, master running on terminal is not able to intercept incoming new connection.
Any help?

Also as i guess server of deepstream 1.1.1 is working over tcp on port 6021 and for browser connection on port 6020.
I guess due to which its not intercepting new incoming connection from android devices ends. As they have now been ported to websockets.

INFO | Listening for tcp connections on 0.0.0.0:6021
INFO | Listening for browser connections on 0.0.0.0:6020

INFO | logger ready
INFO | deepstream version: 1.1.1
INFO | configuration file loaded from conf/config.yml
INFO | library directory set to: /Aman/SafariDwn/deepstream.io-mac-1.1.1/lib
INFO | messageConnector ready
INFO | storage ready
INFO | cache ready
INFO | authenticationHandler ready: none
INFO | permissionHandler ready: valve permissions loaded from /Aman/SafariDwn/deepstream.io-mac-1.1.1/conf/permissions.yml
INFO | Using uws websocket server
CLUSTER_JOIN | iue0xld0-1p6wr8svgmgw4
INFO | Listening for tcp connections on 0.0.0.0:6021
INFO | Listening for browser connections on 0.0.0.0:6020
INFO | Deepstream started
INCOMING_CONNECTION | from 127.0.0.1:53702 via tcp
AUTH_SUCCESSFUL | open

@yasserf
Copy link
Contributor

yasserf commented Oct 17, 2016

Yeah, your currently using the binary version. I'm trying to get a binary built but unfortunately travis isn't enough to spit that. Will let you know as soon as it's sorted

@amanaman118
Copy link
Author

Yes, waiting for binary releases of Deepstream server to check stuff working end to end at my end.

Can you help me how to emit event from master end to client ends for some specific devices connected.
Ex. let suppose their are 10k user connected to DS (deepstream) and subscribe to some event '57fb28b9ef70ca0d6238df2d/commands' and now i want to send event from master to client to only 2k users who are connected to DS out of 10k
How to emit target specific set of users only?

@yasserf
Copy link
Contributor

yasserf commented Oct 17, 2016

I think you might be looking for a different messaging paradigm. In pub-sub every client that subscribes to an event will receive the associated message on that event. For more granular sending of messages, just use more granular patterns.

@amanaman118
Copy link
Author

Oky, i am bit confused what to use to target certain set of user base. What i have unique for every device is device-id and its alpha numeric.

@jdmnd
Copy link
Contributor

jdmnd commented Oct 18, 2016

Hi @amanaman118
We've just published a beta version of deepstream v1.2.0 that uses pure websockets, which might fix some of the issues that you're having. The mac release currently has a broken config.yml, but if you delete that (or just the logging section), it should work fine.

@amanaman118
Copy link
Author

Hi, @jdmnd thnx for putting up effort to provide me release of web-sockets.

I have downloaded v1.2.0 beta and tried it running. Its started fine after getting it running after commenting out logging part in config.yml file.'

I have tried running web-socket java client from android device shared by @yasserf , but its not working as expected. I am getting connection time out issue.

After bit of debugging to got know that under Connection class authenticate() function.
if( this.connectionState == ConnectionState.AWAITING_AUTHENTICATION )
above line shows that connectionState is Closed. I guess due to which connection is not getting connected.

@amanaman118
Copy link
Author

Hello @yasserf

I have tried your's latest release of websocket server 2.0.0rc1 and its working fine on websockets

But after bit of change in master-clone of java client repo i started working as expected.

Under class 'Connection.java' their is a function 'handleConnectionResponse' if i comment below line to check authArgument then its working fine. As if we don't use any argument in deepstream login() function, then below code block doesn't send over authentication message to server and Ping-Pong keeps on happening between server and client. Auth timeout happens after sometime.
Can you please update below issue in codebase. Or let me know any other thing i am missing to set authentication argument. As i guess using of authenticate is made mandatory.

else if( message.action == Actions.ACK ) {
            this.setState( ConnectionState.AWAITING_AUTHENTICATION );
            //if( this.authParameters != null )
            {
                this.sendAuthMessage();
            }
        }

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

3 participants