Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Goole app engine jar pubnub subscribe didnt go in successCallback #7

Closed
DivyeshRupawala opened this issue Jun 17, 2013 · 12 comments
Closed
Assignees

Comments

@DivyeshRupawala
Copy link

I am using google app engine 1.7.4 java.i didn't used python.and i used python google app engine jar for pubnub.

after subscribe called didn't go in successCallback but after i publish any message that i will get message in successCallback.

for that reason i didn't create multiple channel. Its doesn't provide
pubnub.subscribe( new String{'channel1','channel2'}, message_receiver )

It's only provide string parameter for subscribe channel.

Thanks & Regards
Divyesh

@ghost ghost assigned devendram Jun 17, 2013
@geremyCohen
Copy link

@DivyeshRupawala

The PubNub Java client for GAE is based on our 3.3 codebase, as 3.4+ uses async, multithreaded requests which are not permitted in GAE.

If you would like to send us an example of what you are trying to do using regular PubNub 3.4 or 3.5, we are happy to assist you in porting it to PubNub for GAE.

geremy

@DivyeshRupawala
Copy link
Author

Thanks for your reply.

My problem is,i created restapi in which when any client open android app the rest will call and that app also send id of that client.

Now i handle restapi so first id subscribe to pubnub and channel name same as client id and now i would like to create another channel for broadcast but i am not able to create using google app engine pubnub jar.

and i would like to set unique uuid for all client that also not possible in GAE.

my code is as follow:
public class PubnubSubscribeServlet extends HttpServlet{

transient private ConfigurationDAO configurationDAO = ConfigurationDAOImpl.getInstance();

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String deviceId = req.getParameter("deviceId");
    if(deviceId != null){
        Configuration configuration = configurationDAO.fetchConfiguration();
        if(configuration != null){
            if(configuration.getPublishKey() != null && configuration.getSubscribeKey() != null){
                Pubnub pubnub = new Pubnub(configuration.getPublishKey(),configuration.getSubscribeKey(),configuration.getSecretKey());
                try {
                    String channelName = Md5Util.convertMd5(deviceId);
                    PubNubReceiver receiver = new PubNubReceiver();
                    pubnub.subscribe(channelName,receiver);
                     pubnub.subscribe("BROADCAST_CHANNEL",receiver);//NOT WORKING
                     pubnub.subscribe( new String{'channel1','channel2'}, receiver)//NOT AVAILABLE
                } catch (PubnubException e) {
                    e.printStackTrace();
                    System.out.println("Error : " + e.getStackTrace());
                }
            }
        }
    }
}

Thanks & Regards
Divyesh R. Rupawala

@geremyCohen
Copy link

@DivyeshRupawala Just to be sure I understand you, these are the two main issues for you:

  1. i would like to create another channel for broadcast but i am not able to create using google app engine pubnub jar.
  2. I would like to set unique uuid for all client that also not possible in GAE.
  1. For # 1, instead of 3 seperate subscribe calls, can you simply issue a pubnub.subscribe( "ch1,ch2,ch3", receiver) (replace ch1,2,3 with your actual channel names). Let me know if that works.

  2. You are asking for the ability to set UUID dynamically, correct?

@DivyeshRupawala
Copy link
Author

Thanks for your help.

now pubnub.subscribe( "ch1,ch2,ch3", receiver) is working fine but another problem is why callback not return from connect method?

i check it out Pubnub-Standardedition-3.4.jar it's return from callback only problem with google app engine pubnub jar it's never return from callback and waiting for new message.because of this issue i am not able to subscribe another channel.and after few minutes it will throw an error thread time out.

yes i would like to set UUID dynamically.

Thanks & Regards
Divyesh R. Rupawala

@geremyCohen
Copy link

Hi Divyesh-

You must remain on GAE_33 branch and 3.3 version, as GAE has restrictions such as single-threaded operation that PubNub for Java 3.4+ does not accomodate (PN for Java 3.4+ uses fully async, multi-threaded operations).

So it sounds like the remaining two issues are connect callback and custom UUID? Please prioritize these fixes... 1-5 (1 is urgent, showstopping, 5 is nice-to-have), and we will discuss at next engineering meeting this week.

@DivyeshRupawala
Copy link
Author

Thanks for your help

Yes this two issue connect callback and custom UUID for my project.
and i need it as soon as possible because my client waiting for my response.

Priority : 1

Thanks & Regards
Divyesh R. Rupawala

@geremyCohen
Copy link

Ok, we'll see what we can do... standby for an update by early next week.
geremy

@devendram
Copy link

Hi Divyesh,

We have made a fix for you regarding setting the UUID on this branch:

https://github.com/pubnub/java/tree/GAE_3.3_branch/java/3.3

Please verify.

Also, we've confirmed that the connectCallback also works using this code:

            resp.setContentType("text/plain");
    resp.getOutputStream().println("hi");
    pubnub.setUUID("test-uuid");
    try {
        pubnub.subscribe("hello_world", new Callback(){

            @Override
            public boolean successCallback(String channel, Object message) {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public void errorCallback(String channel, Object message) {
                // TODO Auto-generated method stub

            }

            @Override
            public void connectCallback(String channel) {
                try {
                    resp.getOutputStream().println("CONNECT");
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }

            @Override
            public void reconnectCallback(String channel) {
                // TODO Auto-generated method stub

            }

            @Override
            public void disconnectCallback(String channel) {
                // TODO Auto-generated method stub

            }

        });
    } catch (PubnubException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

@geremyCohen
Copy link

@DivyeshRupawala Since our GAE code is single-threaded and blocking by design (since GAE does not allow multithreaded code), based on what you are trying to achieve, it may not work... if it still does not work the way you expect, please:

  1. Send us your code
  2. Tell us what you are trying to do, and describe how the current PubNub for GAE Client behaves differently than how you would expect it to.

geremy

@DivyeshRupawala
Copy link
Author

@geremyCohen
@devendram

Thanks for your your help

My problem is now resolved.Now i am able to set UUID and also create multiple channel using
pubnub.subscribe( "ch1,ch2,ch3", receiver)

Thanks & Regards
Divyesh R. Rupawala

@DivyeshRupawala
Copy link
Author

close #7 fixed

@geremyCohen
Copy link

@DivyeshRupawala great! Let us know what else we can assist with.

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

No branches or pull requests

3 participants