messagebird / java-rest-api

This repository contains the open source Java client for MessageBird's REST API.
https://www.messagebird.com/developers/java
BSD 3-Clause "New" or "Revised" License
48 stars 80 forks source link

SMS message delivered but getting Exception #226

Open moritzsu opened 1 year ago

moritzsu commented 1 year ago

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?

DevPJ9 commented 1 year ago

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.

moritzsu commented 1 year ago

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

denizkilic commented 1 year ago

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?

moritzsu commented 1 year ago

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.