powered by Jive Software

Smack 4.1.3 Strophe Send Message Delay


#1

I’m using Smack 4.1.3 on an Android App to send and receive messages from Strophe Web client. In both applications I’m using BoshConnections. The messages are sent and received correctly, but when I send a message from the Android app, it takes 1-2 mins for Strophe client to get the message. However, if during that interval, I send a message from Strophe to Android app, the message that is pending arrives immediately in the Android App. Also the messages sent from strophe arrive immediately in the android app. Thanks

This is the code I’m using for listening for messages:

**public void MessageListener(){
if(chatManager == null && commonChat == null){
chatManager = ChatManager.getInstanceFor(boshConnection);
chatManager.addChatListener(new ChatManagerListener() {
@Override
public void chatCreated(Chat chat, boolean createdLocally) {
commonChat = chat;
chat.addMessageListener(new ChatMessageListener() {
@Override
public void processMessage(Chat chat, Message message) {
if (message.getBody() != null) {
commonChat = chat;
String fromUser = chat.getParticipant();
String msgBody = message.getBody();
String messageToShow = fromUser + “:” + msgBody;
Log.i(TAG, fromUser + “:” + messageToShow);
**

And for sending messages:

public void SendMessagebyUser(String userName, String message){

** if(isUserOnline(userName)){**

** try {**

** if(commonChat !=null) {**

** commonChat.sendMessage(message);
**

** }**

** else{**

** Chat chatOBJ = chatManager.createChat(userName);**

** chatOBJ.sendMessage(message);**

** }
**

** } catch (Exception e) {**

** Log.i(TAG, “User not connected exception”);**

** e.printStackTrace();**

** }**

** }**

}


#2

It’s a known, but yet untracked, issue. Several people have reported similar behavior (delays, poor performance):

android bosh problem

asmack bosh not behave like it should

Anyone using Smack with the BOSH connection?

Smack Android with openfire performance

Message Sending Using Smack BoshConnection is very slow


#3

Thanks you for your answer. Do you know if there is another solution? Or an alternative?

I was thinking of modifying the library to see where that delay is happening, do you have any suggestion on where to start?


#4

Hi,

We were getting same issue and one solution worked, we backed-up data and then removed all data from OpenFire then added only users again to openfire. This solution worked for us. Hope this will help for you too. We didn’t find the issue but found solution.