2

I have a simple java lambda function which is exposed as a HTTP endpoint using API gateway. When a function is invoked, i send a message to pubnub. Locally, everything works fine but on aws, message is never received on the channel.

I tried playing with polices with no luck. I am wondering if i need to enable any policies to allow outbound connections, if so how ?

I am using pubnub 3.7.5 library. Here is the code being invoked by lambda function.

public class PubNubService {

private static final String publishKey = "pub-c-xxxxxxxxxxxxxxxx";
private static final String subscribeKey = "sub-c-xxxxxxxxxxxxxxxxxxxxx";
private static final String secretKey = "sec-xxxxxxxxxxxxxxxxxxxxxxx";

private Pubnub pubnub = new Pubnub(publishKey, subscribeKey, secretKey);


public void pushMessage(String channelName, JSONObject message) {   
    System.out.println("Sending message on channel:"+channelName+":::"+message);
    Callback callback = new Callback() {
        public void successCallback(String channel, Object response) {
            System.out.println(response.toString());
        }

        public void errorCallback(String channel, PubnubError error) {
            System.out.println(error.toString());
        }
    };
    pubnub.publish(channelName, message, callback);
}
/*
public static void main(String[] args){
    PubNubService nubService = new PubNubService();
    JSONObject message = new JSONObject();
    message.put("status", RequestStatus.REQUEST.toString());
    message.put("requestId", "test");
    message.put("location", "Unknown");
    message.put("message", "message");
    nubService.pushMessage("6ZNq1JXqFla13VFGTRAEcL0w0aCyKjQZ", message);
}*/


}
hechoo
  • 101
  • 1
  • 4
  • 1
    Lambda functions have outbound network with no further configuration required. It may be a problem with credentials. Have you tried logging output to see what's going on? – Ben Whaley Oct 13 '15 at 05:48
  • Pubnub is asynchronous when sending messages and not seeing any errors in call back. Same code i deployed on an ec2 instance and configured policy to allow all outbound connections, its working fine. – hechoo Oct 14 '15 at 14:05
  • 1
    Can you send details about your implementation, including your code and PubNub SDK/version to support@pubnub.com and we'll post back answer here. – Craig Conover Oct 19 '15 at 18:53

0 Answers0