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);
}*/
}