ably-java icon indicating copy to clipboard operation
ably-java copied to clipboard

Issue when trying to reinitialise Push Notifications after logging out (without exiting the app)

Open markcoxsmith opened this issue 5 years ago • 3 comments

Client Comments I’m having issue when trying to reinitialize ably pn after logout (without exiting app). When logout, our idm remove ably device id from ably side. On app side, i did these things: val activationContext = ActivationContext.getActivationContext(appContext) realtime.close() activationContext.activationStateMachine.reset() activationContext.reset() firebaseUtil.revokeToken() // delete FirebaseInstanceId but the shared preferences still have the ABLY things (key startWith ABLY) and if i do login again, it prints these error:

W/System.err( 6401): java.io.IOException: unexpected end of stream on com.android.okhttp.Address@<REDACTED>
W/System.err( 6401): 	at com.android.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:203)
W/System.err( 6401): 	at com.android.okhttp.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:129)
W/System.err( 6401): 	at com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:750)
W/System.err( 6401): 	at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:622)
W/System.err( 6401): 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:475)
W/System.err( 6401): 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)
W/System.err( 6401): 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:542)
W/System.err( 6401): 	at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:106)
W/System.err( 6401): 	at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:30)
W/System.err( 6401): 	at io.ably.lib.http.HttpCore.readResponse(HttpCore.java:392)
W/System.err( 6401): 	at io.ably.lib.http.HttpCore.httpExecute(HttpCore.java:249)
W/System.err( 6401): 	at io.ably.lib.http.HttpCore.httpExecute(HttpCore.java:156)
W/System.err( 6401): 	at io.ably.lib.http.HttpCore.httpExecuteWithRetry(HttpCore.java:74)
W/System.err( 6401): 	at io.ably.lib.http.HttpScheduler$AsyncRequest.httpExecuteWithRetry(HttpScheduler.java:305)
W/System.err( 6401): 	at io.ably.lib.http.HttpScheduler$AblyRequestWithFallback.run(HttpScheduler.java:200)
W/System.err( 6401): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err( 6401): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err( 6401): 	at java.lang.Thread.run(Thread.java:919)
W/System.err( 6401): Caused by: java.io.EOFException: \n not found: size=0 content=...
W/System.err( 6401): 	at com.android.okhttp.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:202)
W/System.err( 6401): 	at com.android.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:188)
W/System.err( 6401): 	... 17 more
I/System.out( 6401): (ERROR): AblyActivation: error updating registration <REDACTED>: [ErrorInfo message=unexpected end of stream on com.android.okhttp.Address@<REDACTED> (See https://help.ably.io/error/50000) code=50000 statusCode=500 href=https://help.ably.io/error/50000]

┆Issue is synchronized with this Jira Bug by Unito

markcoxsmith avatar Nov 30 '20 15:11 markcoxsmith

  • Error is thrown at ActivationStateMachine.java:L446, due to L436
 http.patch("/push/deviceRegistrations/" + device.id, ably.push.pushRequestHeaders(true), params, body, null, false, callback);
  • Error is thrown due to IOExceotion and the error object is being built here : ErrorInfo.java: L148

sacOO7 avatar Dec 21 '20 19:12 sacOO7

Possible solutions

  • https://github.com/square/okhttp/issues/3590
  • https://www.programmersought.com/article/3237644810/
  • https://www.gitmemory.com/issue/square/okhttp/2738/515960916

sacOO7 avatar Dec 21 '20 20:12 sacOO7

  • According to the exception log, it seems the error is definitely from the server. because it returns an empty response for this particular request.
  • https://stackoverflow.com/questions/61422009/retrofit-post-java-io-ioexception-unexpected-end-of-stream-on-connection-caused
  • It will be great if we can understand the particular payload being used for the current http patch request.

sacOO7 avatar Dec 21 '20 20:12 sacOO7