我有一个简单的java lambda函数,它使用API网关作为HTTP端点公开。调用函数时,我向pubnub发送一条消息。在本地,一切正常,但在aws上,消息从未在频道上收到。
我试着玩没有运气的政策。我想知道我是否需要启用任何策略来允许出站连接,如果是这样的话?
我正在使用pubnub 3.7.5库。这是lambda函数调用的代码。
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);
}*/
}