I have Xmpp stack based on Ejabberd(version 16.04) and Smack client library(4.17 on Android).
I'm facing a situation where messages sent by server get dropped, when the client goes offline temporarily. Here are the steps I use to replicate the situation, along with the logs from ejabberd.
1- Client A goes online
2016-06-19 01:22:59.834 [info] <0.505.0>#ejabberd_listener:accept:333 (#Port<0.19955>) Accepted connection 122.172.241.21:26683 -> 139.162.34.247:5222
2016-06-19 01:23:00.449 [info] <0.667.0>#ejabberd_c2s:wait_for_sasl_response:900 ({socket_state,gen_tcp,#Port<0.19955>,<0.666.0>}) Accepted authentication for 9739937980 by undefined from 122.172.241.21
2016-06-19 01:23:00.619 [info] <0.667.0>#ejabberd_c2s:open_session:1111 ({socket_state,gen_tcp,#Port<0.19955>,<0.666.0>}) Opened session for 9739937980#gappi.in/Smack
2016-06-19 01:23:00.698 [info] <0.667.0>#ejabberd_c2s:handle_enable:2700 Stream management with resumption enabled for 9739937980#gappi.in/Smack
2 - Client A is disconnected uncleanly(wifi disconnected or app is killed)
2016-06-19 01:27:57.582 [info] <0.667.0>#ejabberd_c2s:fsm_next_state:2454 Waiting for resumption of stream for 9739937980#gappi.in/Smack
3 - Other client/bots send message to client A
4 - Client A comes back on line after a short while( 60 seconds)
2016-06-19 01:28:39.367 [info] <0.505.0>#ejabberd_listener:accept:333 (#Port<0.19963>) Accepted connection 122.172.241.21:26543 -> 139.162.34.247:5222
2016-06-19 01:28:40.050 [info] <0.684.0>#ejabberd_c2s:wait_for_sasl_response:900 ({socket_state,gen_tcp,#Port<0.19963>,<0.683.0>}) Accepted authentication for 9739937980 by undefined from 122.172.241.21
2016-06-19 01:28:40.213 [info] <0.684.0>#ejabberd_c2s:open_session:1111 ({socket_state,gen_tcp,#Port<0.19963>,<0.683.0>}) Opened session for 9739937980#gappi.in/Smack
2016-06-19 01:28:40.214 [info] <0.667.0>#ejabberd_c2s:terminate:1758 ({socket_state,gen_tcp,#Port<0.19955>,<0.666.0>}) Replaced session for 9739937980#gappi.in/Smack
2016-06-19 01:28:40.215 [info] <0.667.0>#ejabberd_c2s:handle_unacked_stanzas:2872 2 stanzas were not acknowledged by 9739937980#gappi.in/Smack
2016-06-19 01:28:40.302 [info] <0.684.0>#ejabberd_c2s:handle_enable:2700 Stream management with resumption enabled for 9739937980#gappi.in/Smack
Now, here ejabberd tells me that it hasn't received acknowledgement for pending messages
2 stanzas were not acknowledged by 9739937980#gappi.in/Smack. Moreover, the messages are not received by Smack library and are dropped.
So obviously, Smack client library is not sending proper acks for the messages after reconnecting. I've tried enabling Stream Management(XEP-198) in my client library code, but its not working. My Smack client connection code looks like:
XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration
.builder();
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
config.setServiceName(serverAddress);
config.setHost(serverAddress);
config.setPort(5222);
config.setDebuggerEnabled(true);
XMPPTCPConnection.setUseStreamManagementDefault(true);
XMPPTCPConnection.setUseStreamManagementResumptionDefault(true);
connection = new XMPPTCPConnection(config.build());
connection.setUseStreamManagement(true);
connection.setUseStreamManagementResumption(true);
What changes do I need to avoid those dropped messages?
Thanks.
I figured it out myself.
There was a bug in my client side code. I was adding ChatMessageListener to the connection very late.
So even though ejabberd was re-sending the messages correctly on resume, without ChatMessageListener those messages were not being acked properly or stored to client side database.
Related
I'm getting this error when trying to connect to the server I opened locally.
It converts ws to http. and put a # sign at the end.
Socket:
final channel = IOWebSocketChannel.connect(Uri.parse('ws://192.168.1.226:10600'));
**Error: **
Restarted application in 1.052ms. D/EGL_emulation(14743): app_time_stats: avg=8757.14ms min=3.84ms max=218720.27ms count=25 E/flutter (14743): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: WebSocketException: Connection to 'http://192.168.1.226:10600#' was not upgraded to websocket
The server was created with .net 4.8.
I would be glad if you help
I want to show the messages sent by the server in the application.
I'm a new RabbitMQ user, I'm trying to update an Android application that uses the mqtt protocol. Using RabbitMQ version 3.8.28, I have in the logFile:
[error] <0.1608.0> Channel error on connection <0.1588.0> (192.168.0.14:50526 -> 192.168.0.14:1883, vhost: '/', user: 'admin'), channel 2:
operation queue.declare caused a channel exception not_found: no queue 'mqtt-subscription-mobile_P093821992223818qos1' in vhost '/'
2022-03-30 15:55:51.147 [info] <0.1585.0> accepting MQTT connection <0.1585.0> (192.168.0.14:50526 -> 192.168.0.14:1883, client id: mobile_P093821992223818)
The queue mqtt-subscription-mobile_P093821992223818qos1 is automatically generated, however in the new version 3.9.14, the error does not appear in the log file and the queue is not generated.
Can someone tell me how can I generate the queue in the new version?
Thank you
I've recently compiled latest ejabberd code from github on my Arch linux machine. I'm new to ejabberd so I may have made a newbie mistake.
I'm facing an issue where in a particular scenario packets do not reach the target client. This happens if the message is sent after client gets disconnected but before client's session is closed due to resume_timeout.
I've followed instructions as mentioned over here https://www.ejabberd.im/faq/tcp , but still I've been unable to handle all cases.
The relevant parts of my ejabberd.yml look like
listen:
-
port: 5222
module: ejabberd_c2s
max_stanza_size: 65536
resend_on_timeout: true
resume_timeout: 60
shaper: c2s_shaper
access: c2s
-
## Not sure if resend_on_timeout is required here
port: 5280
module: ejabberd_http
resend_on_timeout: true
resume_timeout: 60
http_bind: true
modules:
...
mod_offline:
access_max_user_messages: max_user_offline_messages
mod_ping:
send_pings: true
ping_interval: 60
timeout_action: kill
Here's the output of ejabberd log corresponding to client's acitivites:
Client A disconnects uncleanly
2016-06-19 10:59:51.369 [info] <0.549.0>#ejabberd_c2s:fsm_next_state:2454 Waiting for resumption of stream for 9739937980#gappi.in/Smack`
Client B Logs in and sends a message to A
2016-06-19 11:00:00.320 [info] <0.510.0>#ejabberd_listener:accept:333 (#Port<0.19876>) Accepted connection 139.162.34.247:41186 -> 139.162.34.247:5222
2016-06-19 11:00:00.575 [info] <0.559.0>#ejabberd_c2s:wait_for_sasl_response:900 ({socket_state,fast_tls,{tlssock,#Port<0.19876>,#Port<0.19877>},<0.558.0>}) Accepted authentication for echo by undefined from 137
2016-06-19 11:00:00.715 [info] <0.559.0>#ejabberd_c2s:open_session:1111 ({socket_state,fast_tls,{tlssock,#Port<0.19876>,#Port<0.19877>},<0.558.0>}) Opened session for echo#gappi.in/13353511976792329881266
2016-06-19 11:00:00.776 [info] <0.559.0>#ejabberd_c2s:handle_enable:2700 Stream management with resumption enabled for echo#gappi.in/13353511976792329881266
2016-06-19 11:00:00.984 [info] <0.559.0>#ejabberd_c2s:terminate:1778 ({socket_state,fast_tls,{tlssock,#Port<0.19876>,#Port<0.19877>},<0.558.0>}) Close session for echo#gappi.in/13353511976792329881266
Client A session is finally closed due to resume_timeout
2016-06-19 11:00:51.370 [info] <0.549.0>#ejabberd_c2s:terminate:1778 ({socket_state,gen_tcp,#Port<0.19869>,<0.548.0>}) Close session for 9739937980#gappi.in/Smack
Client A logs back in
2016-06-19 11:01:14.078 [info] <0.510.0>#ejabberd_listener:accept:333 (#Port<0.19879>) Accepted connection 122.172.241.21:26597 -> 139.162.34.247:5222
2016-06-19 11:01:14.707 [info] <0.566.0>#ejabberd_c2s:wait_for_sasl_response:900 ({socket_state,gen_tcp,#Port<0.19879>,<0.565.0>}) Accepted authentication for 9739937980 by undefined from 122.172.241.21
2016-06-19 11:01:14.868 [info] <0.566.0>#ejabberd_c2s:open_session:1111 ({socket_state,gen_tcp,#Port<0.19879>,<0.565.0>}) Opened session for 9739937980#gappi.in/Smack
2016-06-19 11:01:14.966 [info] <0.566.0>#ejabberd_c2s:handle_enable:2700 Stream management with resumption enabled for 9739937980#gappi.in/Smack
As per this guide, https://www.ejabberd.im/faq/tcp, after the resume_timeout expires, the unacked messages should have been handled by mod_offline. But this is not happening.
Result : No message reaches client.
Any pointers?
This problem was due to a bug in Ejabberd https://github.com/processone/ejabberd/issues/1160 which has been fixed now.
I recently setup ejabberd server on macos X 10.7. The server seems to be running fine and admin page is accessible via internet using http://abc.example.com:5280/admin.
I installed "simple XMPP client", "ChatSecure" and other xmpp chat client in my android phone to connect to my ejabberd server. All of them failed. When I try to connect, I can see following line in ejabberd logs
2015-07-29 23:28:58.380 [info] <0.573.0>#ejabberd_listener:accept:299 (#Port<0.7250>) Accepted connection 182.70.123.139:55402 -> 192.168.1.4:5280
2015-07-29 23:37:51.844 [info] <0.571.0>#ejabberd_listener:accept:299 (#Port<0.7277>) Accepted connection 182.70.123.139:10751 -> 192.168.1.4:5222
however, login times out on xmpp chat client. Not sure what's causing this issue. When I install similar xmpp clients on the same box where ejabberd server is running and try to connect using bob#abc.example.com , it works fine.
The issue is only coming when I use some remote machine or phone. Login doesn't work even though request is reaching to ejabberd server.
Please help
Updated post after below suggestion from raymond
Hi, Raymond
Here is the updated logs post debug mode. It is stuck at last line. Please suggest.
2015-07-30 21:16:46.450 [info] <0.566.0>#ejabberd_listener:accept:299 (#Port<0.7012>) Accepted connection 1.39.10.237:46913 -> 192.168.1.4:5222
2015-07-30 21:16:46.889 [debug] <0.586.0>#ejabberd_receiver:process_data:349 Received XML on stream = <<"<stream:stream to=\"abc.example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">">>
2015-07-30 21:16:46.889 [debug] <0.587.0>#ejabberd_c2s:send_text:1901 Send XML on stream = <<"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='129956901' from='abc.example.com' version='1.0' xml:lang='en'>">>
2015-07-30 21:16:46.890 [debug] <0.587.0>#ejabberd_c2s:send_text:1901 Send XML on stream = <<"<stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='5m6LdO+13BLJZeS37oD5PF54bGY='/><register xmlns='http://jabber.org/features/iq-register'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms></stream:features>">>
when I try to connect using xmpp client on the same machine as ejabberd is running, its working and below is log snippet of it.I am not getting "Auth" line when I try to connect using remote machine or android device over internet.
2015-07-30 21:47:46.149 [info] <0.566.0>#ejabberd_listener:accept:299 (#Port<0.7017>) Accepted connection 182.70.123.139:55949 -> 192.168.1.4:5222
2015-07-30 21:47:46.150 [debug] <0.617.0>#ejabberd_receiver:process_data:349 Received XML on stream = <<"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<stream:stream to=\"abc.example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">">>
2015-07-30 21:47:46.150 [debug] <0.618.0>#ejabberd_c2s:send_text:1901 Send XML on stream = <<"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='1273758616' from='abc.example.com' version='1.0' xml:lang='en'>">>
2015-07-30 21:47:46.152 [debug] <0.618.0>#ejabberd_c2s:send_text:1901 Send XML on stream = <<"<stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='5m6LdO+13BLJZeS37oD5PF54bGY='/><register xmlns='http://jabber.org/features/iq-register'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms></stream:features>">>
2015-07-30 21:47:46.156 [debug] <0.617.0>#ejabberd_receiver:process_data:349 Received XML on stream = <<"<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"DIGEST-MD5\">dXNlcm5hbWU9ImFkbWluIixyZWFsbT0iY2hhdC52b3Rlc3VwLmNvbSIsbm9uY2U9IjM3OTYwNjcwNDYiLGNub25jZT0iQitjNDNpZkZ1d3NvN2JzYXRrMGRGT3N6dDJNTGhrZ2o3YkF2bWJGVyt3Yz0iLG5jPTAwMDAwMDAyLHFvcD1hdXRoLG1heGJ1Zj02NTUzNixkaWdlc3QtdXJpPSJ4bXBwL2NoYXQudm90ZXN1cC5jb20iLHJlc3BvbnNlPWE0Nzg1MTc2ZGE0MzdkOWYyNzBmMjhmODc5ZmZhYjQx</auth>">>
If the connection is just slow (timeout), it could be because of carrier slowing down the traffic on port 5222.
To validate this hypothesis, you should:
Use ejabberd debug log level to see if the negociation is progressing (even slowly).
Try to connect on port 5223 in pure SSL to see if it faster.
Try to run ejabberd on another port like 443 that is unlikely to be slowed down by your mobile provider.
I found the discussion here: How do I disconnect my XMPPPY client object? and it concludes with saying that .disconnect() is the right way to do it.
This is the code:
while True:
try:
client.Process(5)
if not client.isConnected:
client.reconnectAndReauth()
except KeyboardInterrupt:
client.disconnect()
break;
flush_queued_messages()
and this is the error that I receive when I press ^C
msg keys: [u'message_type', u'from', u'message_id']
DEBUG: socket got
DEBUG: socket got
DEBUG: socket got
^C DEBUG: socket sent </stream:stream>
DEBUG: socket error Socket error while receiving data
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/xmpp/transports.py", line 146, in receive
try: received = self._recv(BUFLEN)
SSLError: [Errno 8] _ssl.c:1415: EOF occurred in violation of protocol
DEBUG: client stop Disconnect detected
DEBUG: socket error Socket operation failed
This server code is from the gcm server implemented using the python sample code at https://developer.android.com/google/gcm/ccs.html
I implemented this because my server stopped receiving messages after a while (SEND is still ok) - I figured I might have too many active connections. It's just that msgs sent to the server are not received consistently. That is another problem that I haven't figured out yet.
I have shifted to Java for implementing the code. It works fine there. The most probable reason is that the documentation is a mess and the disconnect function is probably not defined well.
Goes without saying that the creating that library was a good effort either way!