本文介绍了XMPP消息失去了对Android的同时切换到数据连接(如转弯,GSM和LT无线上网; - > wifi开关)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发Android的一个聊天应用程序。使用XMPP服务器。 PHP服务器已迁移到ejabber。

我的通知正常工作在所有情况下。但是,在一个情况下,我失去了XMPP消息。其实我没有得到通知。

在详细地说,我关闭WiFi或数据连接。并关闭WiFi或数据连接发送给我的任何通知后没有得到。当我打开的WiFi或数据连接后,我没能得到哪些是发给我的消息。

在后台的我已经实现的服务。这使得XMPP连接永远活。

我得到这个错误,而我关闭了WiFi连接。

  java.net.SocketException异常:SENDTO失败:EPIPE(中断的管道)
java.net.SocketException异常:recvfrom的失败:ETIMEDOUT(连接超时)
   在libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:506)
   在libcore.io.IoBridge.sendto(IoBridge.java:475)
   在java.net.PlainSocketImpl.write(PlainSocketImpl.java:508)
   在java.net.PlainSocketImpl.access $ 100(PlainSocketImpl.java:46)
   在java.net.PlainSocketImpl $ PlainSocketOutputStream.write(PlainSocketImpl.java:270)
   在java.io.OutputStreamWriter.flushBytes(OutputStreamWriter.java:167)
   在java.io.OutputStreamWriter.flush(OutputStreamWriter.java:158)
   在java.io.BufferedWriter.flush(BufferedWriter.java:124)
   在org.jivesoftware.smack.PacketWriter.writePackets(PacketWriter.java:286)
   在org.jivesoftware.smack.PacketWriter.access $ 12(PacketWriter.java:270)
   在org.jivesoftware.smack.PacketWriter $ 1.运行(PacketWriter.java:137)
致:libcore.io.ErrnoException:SENDTO失败:EPIPE(中断的管道)
   在libcore.io.Posix.sendtoBytes(本机方法)
   在libcore.io.Posix.sendto(Posix.java:146)
   在libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
   在libcore.io.IoBridge.sendto(IoBridge.java:473)
   ... 9个
   在libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:552)
   在libcore.io.IoBridge.recvfrom(IoBridge.java:516)
   在java.net.PlainSocketImpl.read(PlainSocketImpl.java:489)
   在java.net.PlainSocketImpl.access $ 000(PlainSocketImpl.java:46)
   在java.net.PlainSocketImpl $ PlainSocketInputStream.read(PlainSocketImpl.java:241)
   在java.io.InputStreamReader.read(InputStreamReader.java:244)
   在java.io.BufferedReader.read(BufferedReader.java:310)
   在org.jivesoftware.smack.XMPPConnection $ AliveReader.read(XMPPConnection.java:1122)
   在org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1496)
   在org.kxml2.io.KXmlParser.peekType(KXmlParser.java:979)
   在org.kxml2.io.KXmlParser.next(KXmlParser.java:346)
   在org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
   在org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:321)
   在org.jivesoftware.smack.PacketReader.access $ 1(PacketReader.java:216)
   在org.jivesoftware.smack.PacketReader $ 1.运行(PacketReader.java:70)
致:libcore.io.ErrnoException:recvfrom的失败:ETIMEDOUT(连接超时)
   在libcore.io.Posix.recvfromBytes(本机方法)
   在libcore.io.Posix.recvfrom(Posix.java:131)
   在libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164)
   在libcore.io.IoBridge.recvfrom(IoBridge.java:513)
   ... 13更多
 

解决方案

所以安装mod_archive我必须这样做,典型:写下面的CMD线。 (对于分OS)

以root身份登录创建新的目录:

 的mkdir ejabberd_archive_plugin
CD ejabberd_archive_plugin
 

现在得到使用下面的命令最新的ejabberd模块

 百胜https://svn.process-one.net/ejabberd-modules
CD的ejabberd模块/ mod_archive /后备箱
运行./build.sh
 

使用下面的CMD现在去EBIN目录,并得到所有的列表* .beam文件的ejabberd存档插件。

 根@ NS1 [/ ejabberd_archive_plugin /的ejabberd模块/ mod_archive /中继/ EBIN]#ls -l命令
 

使用下面的CMD,你会得到所有的ejabberd * .beam文件列表时的ejabberd安装和配置。

 根@ NS1 [在/ usr / lib64下/的ejabberd / EBIN]#ls -l命令
 

现在复制所有* .beam(存档插件)文件的ejabberd EBIN目录中使用以下CMD

 根@ NS1 [/]#CP / ejabberd_archive_plugin /的ejabberd模块/ mod_archive /中继/ EBIN在/ usr / lib64下/的ejabberd / EBIN
 

现在去下面的网址,并复制SQL表查询,并在phpMyAdmin运行(的ejabberd数据库)

<$p$p><$c$c>https://svn.process-one.net/ejabberd-modules/mod_archive/trunk/src/mod_archive_odbc_mysql.sql

使用现在配置ejjaberd.cfg以下CMD

 根@ NS1 [/等/的ejabberd]#六ejabberd.cfg
添加下面一行到ejabberd.cfg文件中的模块配置部分
{mod_archive_odbc,[{DATABASE_TYPE,MySQL的},{default_auto_save,真},{enforce_default_auto_save,真}]},
 

现在重新启动的ejabberd服务。

 根@ NS1 [/等/的ejabberd]#须藤服务的ejabberd重启
 

I'm developing a chat application in android. Using XMPP server. PHP server has been migrated to ejabber.

My notification works properly in all scenarios. But in one case I am losing the XMPP messages. In fact I am not getting notifications.

In detail, I am turning off the WiFi or data connection. and after turning off WiFi or data connection any notification sent to me that is not getting. after when I turn ON the WiFi or data connection, I am not able to get the messages which were sent to me.

I have implemented service in background. that makes xmpp connection always live.

I getting this error while i turn OFF the WiFi connection.

java.net.SocketException: sendto failed: EPIPE (Broken pipe)
java.net.SocketException: recvfrom failed: ETIMEDOUT (Connection timed out)
   at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:506)
   at libcore.io.IoBridge.sendto(IoBridge.java:475)
   at java.net.PlainSocketImpl.write(PlainSocketImpl.java:508)
   at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)
   at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:270)
   at java.io.OutputStreamWriter.flushBytes(OutputStreamWriter.java:167)
   at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:158)
   at java.io.BufferedWriter.flush(BufferedWriter.java:124)
   at org.jivesoftware.smack.PacketWriter.writePackets(PacketWriter.java:286)
   at org.jivesoftware.smack.PacketWriter.access$12(PacketWriter.java:270)
   at org.jivesoftware.smack.PacketWriter$1.run(PacketWriter.java:137)
Caused by: libcore.io.ErrnoException: sendto failed: EPIPE (Broken pipe)
   at libcore.io.Posix.sendtoBytes(Native Method)
   at libcore.io.Posix.sendto(Posix.java:146)
   at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
   at libcore.io.IoBridge.sendto(IoBridge.java:473)
   ... 9 more
   at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:552)
   at libcore.io.IoBridge.recvfrom(IoBridge.java:516)
   at java.net.PlainSocketImpl.read(PlainSocketImpl.java:489)
   at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
   at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:241)
   at java.io.InputStreamReader.read(InputStreamReader.java:244)
   at java.io.BufferedReader.read(BufferedReader.java:310)
   at org.jivesoftware.smack.XMPPConnection$AliveReader.read(XMPPConnection.java:1122)
   at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1496)
   at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:979)
   at org.kxml2.io.KXmlParser.next(KXmlParser.java:346)
   at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
   at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:321)
   at org.jivesoftware.smack.PacketReader.access$1(PacketReader.java:216)
   at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
Caused by: libcore.io.ErrnoException: recvfrom failed: ETIMEDOUT (Connection timed out)
   at libcore.io.Posix.recvfromBytes(Native Method)
   at libcore.io.Posix.recvfrom(Posix.java:131)
   at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164)
   at libcore.io.IoBridge.recvfrom(IoBridge.java:513)
   ... 13 more
解决方案

So to install mod_archive I need to do this, the typical:Write following line in cmd. (For cent Os)

Login as rootCreate new directory:

mkdir ejabberd_archive_plugin
cd ejabberd_archive_plugin

now get the latest ejabberd modules using following command

yum https://svn.process-one.net/ejabberd-modules
cd ejabberd-modules/mod_archive/trunk
./build.sh

Now go to ebin directory using following cmd and get the list of all *.beam files for ejabberd archive plugins.

root@ns1 [/ejabberd_archive_plugin/ejabberd-modules/mod_archive/trunk/ebin]# ls –l

Using following cmd you will get all ejabberd *.beam files list when ejabberd setup and configure.

root@ns1 [/usr/lib64/ejabberd/ebin]# ls -l

Now copy all *.beam (archive plugins) files to ejabberd ebin directory using following cmd

root@ns1 [/]# cp /ejabberd_archive_plugin/ejabberd-modules/mod_archive/trunk/ebin   /usr/lib64/ejabberd/ebin

Now go to following URL and copy all sql table queries and run in phpmyadmin (ejabberd database)

https://svn.process-one.net/ejabberd-modules/mod_archive/trunk/src/mod_archive_odbc_mysql.sql

Now configure ejjaberd.cfg using following cmd

root@ns1 [/etc/ejabberd]# vi ejabberd.cfg 
Add the following line into ejabberd.cfg file in modules configuration section
{mod_archive_odbc, [{database_type, "mysql"}, {default_auto_save, true}, {enforce_default_auto_save, true}]},

Now restart the ejabberd service.

root@ns1 [/etc/ejabberd]# sudo service ejabberd restart

这篇关于XMPP消息失去了对Android的同时切换到数据连接(如转弯,GSM和LT无线上网; - &GT; wifi开关)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 00:43