-->

PubNub publish not working

2019-08-16 09:20发布

问题:

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?



标签: pubnub