TwidereProject / Twidere-Android

http://twidere.com
2.75k stars 377 forks source link

Cannot post to Mastodon #997

Closed kuba-orlik closed 6 years ago

kuba-orlik commented 6 years ago

Expected behavior

Posting to Mastodon sends the post to Mastodon

Actual behavior

A "Network error: timeout" toast appears and the post is not sent

Steps to reproduce

  1. Setup a mastodon.host account in Twidere
  2. Open the "Compose" dialog, and enter some text
  3. Click "send"
  4. Notice the error message

Extra info

Android version: 7.1.2

Network type:

App version: 3.7.1

Build variant:

Micro-blogging service:

App settings:

ghost commented 6 years ago

@kuba-orlik Try either Mastalab or Tusky for Mastodon. For Twidere, the priority is Twitter, not Mastodon.

kuba-orlik commented 6 years ago

It eventually worked, but is very sketchy. It's a shame, I saw Twidere as a way to easilly cross-post

mariotaku commented 6 years ago

"Connection timeout" error is network related. Either your network was slow or mastodon instance failed to respond.

trwnh commented 6 years ago

Mastodon posting works fine for me on mastodon.social and anticapitalist.party, so I don't think this is a bug in Twidere. Also, mastodon.host failed to load in a web browser while typing this comment, so it's definitely problems with their host. Trying again succeeded, but it took some time.

jdfq commented 6 years ago

我也不能发布。刷新信息正常,所以觉得可能是APP的问题

jdfq commented 6 years ago

好像发布成功了。国内网络本来就不好。

HugoPoi commented 4 years ago

I encounter this issue a lot, on my own mastodon server, and only with Twidere client. And I can reproduce especially when I have big media attached, the media upload goes well, then the posting take multiple seconds and failed with just "timeout" toast.

5-10 02:20:52.200  5841  5841 W Twidere : 
05-10 02:20:52.200  5841  5841 W Twidere : org.mariotaku.twidere.task.twitter.UpdateStatusTask$UploadException: timeout
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.twidere.task.twitter.UpdateStatusTask$Companion.uploadMastodonMedia(UpdateStatusTask.kt:764)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.twidere.task.twitter.UpdateStatusTask.uploadMediaWithDefaultProvider(UpdateStatusTask.kt:387)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.twidere.task.twitter.UpdateStatusTask.uploadMedia(UpdateStatusTask.kt:175)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.twidere.task.twitter.UpdateStatusTask.doUpdateStatus(UpdateStatusTask.kt:117)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.twidere.task.twitter.UpdateStatusTask.doLongOperation(UpdateStatusTask.kt:78)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.twidere.task.twitter.UpdateStatusTask.doLongOperation(UpdateStatusTask.kt:66)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.abstask.library.AbstractTask.invokeExecute(AbstractTask.java:69)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.abstask.library.ManualTaskStarter.invokeExecute(ManualTaskStarter.java:22)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.twidere.service.LengthyOperationsService.updateStatuses(LengthyOperationsService.kt:313)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.twidere.service.LengthyOperationsService.handleUpdateStatusIntent(LengthyOperationsService.kt:230)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.twidere.service.LengthyOperationsService.onHandleIntent(LengthyOperationsService.kt:91)
05-10 02:20:52.200  5841  5841 W Twidere :  at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:76)
05-10 02:20:52.200  5841  5841 W Twidere :  at android.os.Handler.dispatchMessage(Handler.java:106)
05-10 02:20:52.200  5841  5841 W Twidere :  at android.os.Looper.loop(Looper.java:193)
05-10 02:20:52.200  5841  5841 W Twidere :  at android.os.HandlerThread.run(HandlerThread.java:65)
05-10 02:20:52.200  5841  5841 W Twidere : Caused by: timeout
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.twidere.util.api.TwidereExceptionFactory.newException(TwidereExceptionFactory.kt:39)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.twidere.util.api.TwidereExceptionFactory.newException(TwidereExceptionFactory.kt:35)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.restfu.RestAPIFactory$RestInvocationHandler.onError(RestAPIFactory.java:232)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.restfu.RestAPIFactory$RestInvocationHandler.invoke(RestAPIFactory.java:196)
05-10 02:20:52.200  5841  5841 W Twidere :  at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
05-10 02:20:52.200  5841  5841 W Twidere :  at $Proxy0.uploadMediaAttachment(Unknown Source)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.twidere.task.twitter.UpdateStatusTask$Companion.uploadMastodonMedia(UpdateStatusTask.kt:758)
05-10 02:20:52.200  5841  5841 W Twidere :  ... 14 more
05-10 02:20:52.200  5841  5841 W Twidere : Caused by: java.net.SocketTimeoutException: timeout
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.java:593)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.java:601)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http2.Http2Stream.takeResponseHeaders(Http2Stream.java:146)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http2.Http2Codec.readResponseHeaders(Http2Codec.java:120)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:75)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
05-10 02:20:52.200  5841  5841 W Twidere :  at okhttp3.RealCall.execute(RealCall.java:69)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.restfu.okhttp3.OkHttpRestClient$OkToRestCall.execute(OkHttpRestClient.java:180)
05-10 02:20:52.200  5841  5841 W Twidere :  at org.mariotaku.restfu.RestAPIFactory$RestInvocationHandler.invoke(RestAPIFactory.java:190)
05-10 02:20:52.200  5841  5841 W Twidere :  ... 17 more
HugoPoi commented 3 years ago

After digging a little I think my mastodon instance is somehow slow to respond on the post API call, so the http socket stay empty too long (processing stuff on the server side) and the java network stack close the connection too early and don't wait enough ?

Maybe we can add a java.net.SocketTimeout settings

I confirm I get a 499 Client Closed Request from nginx on the server side !

 - - [27/Sep/2020:12:35:57 +0200] "POST /api/v1/media HTTP/2.0" 499 0 "-" "Twidere/4.1.4 okhttp/3.12.12 Android/10"

https://github.com/TwidereProject/Twidere-Android/blob/aba0d0be0e1a489f319de5abc937ff1337b24d0c/twidere/src/main/kotlin/org/mariotaku/twidere/util/HttpClientFactory.kt#L191-L211

So If I'm not mistaken, we can't set the readTimeout/writeTimeout, the app using the default 10 seconds according to the documentation.