Google Sites API caused com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:52)

StackOverflow https://stackoverflow.com/questions/17215744

  •  01-06-2022
  •  | 
  •  

Вопрос

java.lang.RuntimeException: Unable to complete the HTTP request
    at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getHeaderFields(URLFetchServiceStreamHandler.java:217)
    at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getHeaderFields(URLFetchServiceStreamHandler.java:73)
    at com.google.gdata.client.http.HttpGDataRequest.isOAuthProxyErrorResponse(HttpGDataRequest.java:566)
    at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:557)
    at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
    at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
    at com.google.gdata.client.Service.getFeed(Service.java:1135)
    at com.google.gdata.client.Service.getFeed(Service.java:998)
    at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:645)
    at com.google.gdata.client.Service.getFeed(Service.java:1017)
    at com.jabil.sites.subscription.service.GoogleSitesService.getFirstContentFeed(GoogleSitesService.java:72)
    at com.jabil.sites.subscription.service.GoogleSitesService.sendNotification(GoogleSitesService.java:150)
    at com.jabil.sites.subscription.servlet.NotifyUsersServlet.sendNotification(NotifyUsersServlet.java:60)
    at com.jabil.sites.subscription.servlet.NotifyUsersServlet.doGet(NotifyUsersServlet.java:40)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.DevAppServerServersFilter.doDirectRequest(DevAppServerServersFilter.java:369)
    at com.google.appengine.tools.development.DevAppServerServersFilter.doDirectServerRequest(DevAppServerServersFilter.java:352)
    at com.google.appengine.tools.development.DevAppServerServersFilter.doFilter(DevAppServerServersFilter.java:115)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:94)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:421)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.net.SocketTimeoutException: Timeout while fetching: https://sites.google.com/feeds/content/mydomain.com/global-communications-programs
    at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:52)
    at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.fetchResponse(URLFetchServiceStreamHandler.java:417)
    at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getInputStream(URLFetchServiceStreamHandler.java:296)
    at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getHeaderFields(URLFetchServiceStreamHandler.java:212)
    ... 50 more
Jun 20, 2013 9:46:40 PM com.mydomain.sites.subscription.service.GoogleSitesService sendNotification

I have this exception message thrown when accessing into this Google Site via Google Sites API. There is no problem when accessing other Google Sites with via Google Sites API.

This is the programming:

private static ContentFeed getFirstContentFeed(SitesService service, String siteName, Credential credential) throws Exception {
    // Configure URL as Google Sites content feed
    String url = String.format(                                                         
                        "%s/%s/%s",
                            GoogleOAuth2Constant.GOOG_SITES_CONTENT_FEED,
                            ReadXmlConfigurationService.getNode("domain"),
                            siteName);                                   

    // Assign Google credential into SitesService
    service.setOAuth2Credentials(credential);                                           
    // Use HTTP-SSL to call Google Sites API
    service.useSsl();                                                                   

    // Retrieve site contents
    return service.getFeed(new URL(url), ContentFeed.class);                            
}

This line caused the exception thrown:

return service.getFeed(new URL(url), ContentFeed.class);

Well, I don't think my programming portion caused the issue because it somehow managed to be called after retries.

Это было полезно?

Решение

Had it solved by adding setConnectionTimeout()

private static ContentFeed getFirstContentFeed(SitesService service,
                                               String siteName,
                                               Credential credential) throws Exception {

    // Configure URL as Google Sites content feed
    String url = String.format(                                                         
                        "%s/%s/%s/",
                            GoogleOAuth2Constant.GOOG_SITES_CONTENT_FEED,
                            ReadXmlConfigurationService.getNode("domain"),
                            siteName);                                   

    // Assign Google credential into SitesService
    service.setOAuth2Credentials(credential);                                           
    // Use HTTP-SSL to call Google Sites API
    service.useSsl();
    // Set HTTP timeout for 2 minutes for larger feed
    service.setConnectTimeout(120000);

    // Retrieve site contents
    return service.getFeed(new URL(url), ContentFeed.class);                            
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top