我有这样的代码,我需要用GAE运行,
public class RootServerResource extends ServerResource {
@Get("json")
public String represent() {
String client = getRequest().getClientInfo().getAddress();
InetAddress addr = null;
try {
addr = InetAddress.getByName(client);
} catch (UnknownHostException e) {
e.printStackTrace();
}
String domain = addr.getHostName();
return "hello, world (from the cloud!), your client domain is: " + domain;
}
}
但它会抛出:
由: com.google.apphosting.api.ApiProxy$FeatureNotEnabledException:引起,一旦在管理控制台中启用计费,套接字API将为此应用程序启用。
在这个问题上有解决办法吗?有什么方法可以用GAE从IP中获取域吗?某种方式下,套接字API将不会被调用。
发布于 2014-08-21 07:11:33
域查找需要出站套接字,因此您需要通过应用程序访问Socket。就像医生说的,Sockets仅适用于付费应用程序。。
一种方法是使用具有HTTP接口的反向域查找服务,如:http://www.statdns.com/api/ (参见在页面末尾获取反向PTR )。
https://stackoverflow.com/questions/25418581
复制