title: Can't make API call urlfetch.Fetch in a thread that is neither the original request thread nor a thread created by ThreadManager
body: <p>I am currently playing with kotlin, Spring social and Google app engine. I am trying to get back a number of followers every second.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>@Service
  class SubscribeService {
      var subscriber : Disposable? = null
      var twitter : Twitter = TwitterTemplate(
              "XXXAUTHXXX",
              "XXXAUTHXXX",
              "XXXAUTHXXX",
              "XXXAUTHXXX")
  
      fun subscribe() {
          subscriber = Observable.interval(1, TimeUnit.SECONDS).subscribe {println(twitter.userOperations().getUserProfile("azeaze").followersCount)}
      }
  
      fun unsubscribe() {
          subscriber?.dispose()
      }
  }    
  </code></pre>
  
  <p>I get this exception when I execute subscribe function : </p>
  
  <pre><code>[INFO] io.reactivex.exceptions.OnErrorNotImplementedException: Can't make API call urlfetch.Fetch in a thread that is neither the original request thread nor a thread created by ThreadManager
  [INFO]  at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
  [INFO]  at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
  [INFO]  at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:74)
  [INFO]  at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:64)
  [INFO]  at io.reactivex.internal.operators.observable.ObservableInterval$IntervalObserver.run(ObservableInterval.java:83)
  [INFO]  at io.reactivex.internal.schedulers.ScheduledDirectPeriodicTask.run(ScheduledDirectPeriodicTask.java:39)
  [INFO]  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
  [INFO]  at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
  [INFO]  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
  [INFO]  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
  [INFO]  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  [INFO]  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  [INFO]  at java.lang.Thread.run(Thread.java:748)
  [INFO] Caused by: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call urlfetch.Fetch in a thread that is neither the original request thread nor a thread created by ThreadManager
  [INFO]  at com.google.apphosting.api.ApiProxy$CallNotFoundException.foreignThread(ApiProxy.java:844)
  [INFO]  at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:116)
  [INFO]  at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:40)
  [INFO]  at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.fetchResponse(URLFetchServiceStreamHandler.java:543)
  [INFO]  at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getInputStream(URLFetchServiceStreamHandler.java:422)
  [INFO]  at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getResponseCode(URLFetchServiceStreamHandler.java:275)
  [INFO]  at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:84)
  [INFO]  at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
  [INFO]  at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
  [INFO]  at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:99)
  [INFO]  at org.springframework.social.oauth1.OAuth1RequestInterceptor.intercept(OAuth1RequestInterceptor.java:48)
  [INFO]  at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:86)
  [INFO]  at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:70)
  [INFO]  at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
  [INFO]  at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
  [INFO]  at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:652)
  [INFO]  at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:628)
  [INFO]  at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:303)
  [INFO]  at org.springframework.social.twitter.api.impl.UserTemplate.getUserProfile(UserTemplate.java:60)
  [INFO]  at tbetous.SubscribeService$test$1.accept(SubscribeService.kt:20)
  [INFO]  at tbetous.SubscribeService$test$1.accept(SubscribeService.kt:11)
  [INFO]  at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60)
  [INFO]  ... 9 more
  [INFO] Exception in thread "RxComputationThreadPool-1" io.reactivex.exceptions.OnErrorNotImplementedException: Can't make API call urlfetch.Fetch in a thread that is neither the original request thread nor a thread created by ThreadManager
  [INFO]  at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
  [INFO]  at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
  [INFO]  at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:74)
  [INFO]  at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:64)
  [INFO]  at io.reactivex.internal.operators.observable.ObservableInterval$IntervalObserver.run(ObservableInterval.java:83)
  [INFO]  at io.reactivex.internal.schedulers.ScheduledDirectPeriodicTask.run(ScheduledDirectPeriodicTask.java:39)
  [INFO]  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
  [INFO]  at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
  [INFO]  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
  [INFO]  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
  [INFO]  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  [INFO]  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  [INFO]  at java.lang.Thread.run(Thread.java:748)
  [INFO] Caused by: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call urlfetch.Fetch in a thread that is neither the original request thread nor a thread created by ThreadManager
  [INFO]  at com.google.apphosting.api.ApiProxy$CallNotFoundException.foreignThread(ApiProxy.java:844)
  [INFO]  at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:116)
  [INFO]  at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:40)
  [INFO]  at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.fetchResponse(URLFetchServiceStreamHandler.java:543)
  [INFO]  at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getInputStream(URLFetchServiceStreamHandler.java:422)
  [INFO]  at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getResponseCode(URLFetchServiceStreamHandler.java:275)
  [INFO]  at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:84)
  [INFO]  at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
  [INFO]  at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
  [INFO]  at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:99)
  [INFO]  at org.springframework.social.oauth1.OAuth1RequestInterceptor.intercept(OAuth1RequestInterceptor.java:48)
  [INFO]  at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:86)
  [INFO]  at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:70)
  [INFO]  at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
  [INFO]  at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
  [INFO]  at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:652)
  [INFO]  at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:628)
  [INFO]  at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:303)
  [INFO]  at org.springframework.social.twitter.api.impl.UserTemplate.getUserProfile(UserTemplate.java:60)
  [INFO]  at tbetous.SubscribeService$test$1.accept(SubscribeService.kt:20)
  [INFO]  at tbetous.SubscribeService$test$1.accept(SubscribeService.kt:11)
  [INFO]  at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60)
  [INFO]  ... 9 more
  </code></pre>
  
  <p>I am pretty sure it is something about google app engine. When I run my application I use <code>mvn appengine:devserver</code>. Can anyone help me ?</p>