PubNub publish not working

匆匆过客 提交于 2020-01-06 19:49:10

问题


I am trying to integrate PubNub with KaaIoT platform where the publish API is throwing the following error/exception:

Following is the code showing a sample message that I am trying to publish:

PNConfiguration pnConfiguration = new PNConfiguration();
        pnConfiguration.setSubscribeKey("sub-c-7c052466-04ea-11e5-aefa-0619f8945XXX");
        pnConfiguration.setPublishKey("pub-c-12a0e504-b46c-4c9c-ba5d-089ae589bYYY");

        PubNub pubNub = new PubNub(pnConfiguration);

        try {
            HashMap<String, String> data = new HashMap<String, String>();
            data.put("value", "39");
            data.put("since", "07:00 AM");

            pubNub.publish()
                    .message(data)
                    .channel("TEMP")
                    .sync();

            System.exit(0);

        } catch(Exception ex) {
            System.out.println("Got PubNubException..." + ex.toString());
            throw ex;
        }

If I try this above sample code as a standalone application, it is working fine. However, inside kaaiot, it is not working. And, I am not able to make out much from the log.

Any idea what might be causing the sync method to fail?


回答1:


Can you call any other rest based endpoint? The SDK is making rest calls under the covers. The log, although not very informative, seems to point to not being able to make a rest call.

It also maybe kaaiot, do they allow generic http request?



来源:https://stackoverflow.com/questions/38037507/pubnub-publish-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!