java-rest-api icon indicating copy to clipboard operation
java-rest-api copied to clipboard

SMS message delivered but getting Exception

Open moritzsu opened this issue 2 years ago • 4 comments

Hello everyone, I am currently trying to send a SMS via MessageBird and show the user an error popup when the message could not be delivered. My SMS always reach their target but a lot of times (I cant tell when exactly) I get an exception from MessageBird which triggers my popup to show up even though the message could be delivered.

I get the following exception (I replaced the part after Adress with placeholder since I dont know if I can share that): java.io.IOException: unexpected end of stream on com.android.okhttp.Address"placeholder" What could be the issue for this?

moritzsu avatar Jan 27 '23 18:01 moritzsu

I think it is related to you not closing connection after every request.

check out this post from stack overflow: https://stackoverflow.com/questions/45838774/java-io-ioexception-unexpected-end-of-stream-on-connection-in-android

Hope this helps.

DevPJ9 avatar Jan 27 '23 19:01 DevPJ9

I am not doing any networking operations, I let all of that be handled by the MessageBird API. The code I am testing with, is pretty much like the example at: https://github.com/messagebird/java-rest-api/blob/master/examples/src/main/java/ExampleSendMessage.java

moritzsu avatar Jan 27 '23 20:01 moritzsu

Hi @moritzsu, Thanks for creating the issue. I found this link on StackOverflow which suggests adding android:usesCleartextTraffic="true". Besides this, I don't see a problem with SDK that could cause this error for now. I will investigate further. Did you find anything on the Android side?

denizkilic avatar Feb 02 '23 14:02 denizkilic

Sadly I did not find anything related to this on my side - I can not replicate the error consistenly either. Since it is not possible for me to use clear text traffic I can not use your solution.

moritzsu avatar Feb 06 '23 10:02 moritzsu