deepstream.io-client-java icon indicating copy to clipboard operation
deepstream.io-client-java copied to clipboard

Events are not being listened from android devices

Open amanaman118 opened this issue 10 years ago • 24 comments

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.

amanaman118 avatar Oct 12 '16 06:10 amanaman118

hey @amanaman118

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

Can you use this version:

https://github.com/deepstreamIO/deepstream.io-client-java/commit/0b6d3043ca4963ff83116c5e14d28d46c8938664

yasserf avatar Oct 12 '16 09:10 yasserf

Thnx @yasserf I have downloaded zipped content of commit id (0b6d3043ca4963ff83116c5e14d28d46c8938664) 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.

amanaman118 avatar Oct 12 '16 10:10 amanaman118

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.

yasserf avatar Oct 12 '16 11:10 yasserf

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)

amanaman118 avatar Oct 12 '16 12:10 amanaman118

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.

yasserf avatar Oct 12 '16 17:10 yasserf

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 avatar Oct 13 '16 05:10 amanaman118

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.

amanaman118 avatar Oct 13 '16 07:10 amanaman118

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!

yasserf avatar Oct 13 '16 08:10 yasserf

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.

amanaman118 avatar Oct 13 '16 08:10 amanaman118

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

yasserf avatar Oct 13 '16 09:10 yasserf

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.

amanaman118 avatar Oct 13 '16 09:10 amanaman118

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?

yasserf avatar Oct 13 '16 12:10 yasserf

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.

amanaman118 avatar Oct 14 '16 05:10 amanaman118

Perfect!

yasserf avatar Oct 14 '16 07:10 yasserf

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.

amanaman118 avatar Oct 17 '16 06:10 amanaman118

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

yasserf avatar Oct 17 '16 09:10 yasserf

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

amanaman118 avatar Oct 17 '16 10:10 amanaman118

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

yasserf avatar Oct 17 '16 12:10 yasserf

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?

amanaman118 avatar Oct 17 '16 13:10 amanaman118

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.

yasserf avatar Oct 17 '16 13:10 yasserf