When two Jabber (XMPP) clients connected, only one is able to receive messages, both can send - xmpp

I have a Windows XMPP client - PSI and an android one - IMO. I'm connected to the same custom server, using two different resources (hostname on desktop, don't know what IMO uses as resource). When someone sends me a message, only desktop client is able to receive it. Android client can only send.
What to configure in clients to be able to receive messages on both clients simultaneously?

Figured it out. XMPP protocol has priorities assigned to resources. See 11.1 in http://xmpp.org/rfcs/rfc3921.html#rules. Valid range is -127 .. +128
IMO sends priority 1 (at least in my version). Setting priority in PSI to -120 made my phone client always receive the message. I'll play with priorities to take advantage of auto-away feature that lowers priority.

If you've got admin permissions on an Openfire server, setting the system property "route.all-resources" to "true" should allow all connected client to receive a message sent to a Jabber ID. This worked in my case.

Related

Is there an out of the box solution for Client-Client communication using the QUICKFIX library?

I'm trying to build a entirely contained trading simulator using quickfix/J. The systems ought to consist of 2 client applications (a market/exchange and a broker) as well as a router (server/acceptor). In particular I'd like to know:
Client-Client communication
How the two clients can communicate to each other, but the server handling all the messaging logic, ie. messages should go through server and it should decide where and how to forward messages. I ought to be able to pass a targetID in FIX message, and the server app should handle routing to desired client.
Multiple clients on same port
Have multiple clients connected on same port but messages should only go to a particular sender comp Id ie. clients should not be privy of communication from other clients.
I've already set up the acceptor, and 2 clients. I know I could do this programmaticaly using plain old Java but I'd like to leverage the quickfix library and would like a relativly out of the box solution.
MVP: client (broker) sends fix message through the acceptor(router), message is processed and forwarded to a particular market, market recieves message through server and does some business logic, market sends fix message back to client through acceptor.
ps: I like the quickfix library but I'm very flexible if there any other library/languages you'd recommend
Short answer: QuickFIX/J (as far as I can tell similarly QuickFIX or quickfix/n) will not route messages based on tags. This has to be implemented in your application code.
Edit: with regard to your second point. There is no problem having your FIX server listening for multiple FIX connections on the same port (This applies for QuickFIX/J and I guess also the other language variants.) Sessions are addressed via the SessionID so it is ensured that only the correct FIX Session gets its messages.

websocket communication between clients in distributed system

I'm trying to build instant messaging app. Clients will not only send messages but also often send audios. And I've decided to use websocket connection to communicate with clients. It is fast and allows to send binary data.
The main idea is to receive from client1 message and notify about it client2. But here's the thing. My app will be running on GAE. And what if client1's socket is opened on server1 and client2's is opened on server2. This servers don't know about each others clients.
I have one idea how to solve it, but I am sure it is shitty way. I am going to use some sort of communication between servers(for example JMS or open another websocket connection between servers, doesn't matter right now).
But it surely will lead to a disaster. I can't even imagine how often those servers will speak to each other. For each message server1 should notify server2, server2 should notify client2. But things become even worse when serverN comes into play.
Another way I see this to work is Firebase. But it restricts message size to 4KB. So I can't send audios via it. As a solution I can notify client about new audio and he goes to my server for it.
Hope I clearly explained the problem. Does anyone know how to solve it? Or maybe there are another ways to build such apps?
If you are building a messaging cluster and expect communicating clients to connect to different instances of the server then server-server communication is inevitable. Usually it's not a problem though.
First, if you don't use any load balancing your clients will connect to the same server 50% of time on average (in case of 2 servers).
Second, intra-datacenter links are fast and free in all known public clouds.
Third, you can often do something smart on the frontend to make sure two likely to communicate clients connect to the same server. For instance direct all clients from the same country to the same server using DNS load balancing.
The second part of the question is about passing large media files. It's a common best practice to send it out of band - store on the server and only pass the reference to it. Like someone suggested in the comment, save the audio on the server and just send a message like "audio is available, fetch it from here ...". You don't need to poll the server for that. Just fetch it once when the receiving client requests it.
In general, it seems like you are trying to reinvent the wheel. Just use something off the shelf.
Let all client get connected to multiple servers and each server keeps this metadata
A centralized system like zookeeper stores active servers details
When a client c1 sends a message to client c2:
the message is received by a server (say s1, we can add a load balancer to distribute incoming requests)
s1 will broadcast this information to all other servers to get which server the client c2 is connected to OR a better approach to use consistent hashing which decides which server the client can connect to & in this approach message broadcast is not required
the corresponding server responses to server s1 (say s2)
now s1 sends the message m to s2 and server s2 to client c2
Cons of the above approach:
Each server will have a connection with the n-1 servers, creating a mesh topology
Centralized system (zookeeper) becomes a single point of failures (which is solvable)
Apps like Whatsapp, G-Talk uses XMPP and TCP/IP.

OpenSIPs + MediaProxy: Cant receive call on 3G

I have a SIP Server running OpenSIPs 1.11.3
configured with built-in STUN module (full mode with 2 IPs)
configured with MediaProxy 2.6.1 to relay RTP (using engage_media_proxy in routing script)
Using IMSDroid from doubango as the SIP client.
Calls between wifi-wifi is good, I do not need to turn on any STUN, ICE, TURN option in the client.
However, calls between 3g-wifi or 3g-3g isn't that good. 3G can make outgoing call but it cannot receive call. Which means 3g-3g call can NEVER happen. All I see in the OpenSIPs logs are repeated retransmissions of INVITE because it cannot reach the 3G side.
I read that TURN server can solve this kind of problem, so I enabled TURN in IMSDroid sip client, but still 3G side cannot receive any call.
The TURN server I am using:
url: 'turn:numb.viagenie.ca'
credential: 'muazkh'
username: 'webrtc#live.com'
Is there any solution / module I can use to solve this problem?
EDIT:
If I use TCP protocol, I am able to receive call! Although the call terminate due to transport error after 30 seconds, but at least the call went through. Any idea what happen here?? Mobile carrier blocking incoming call? But definitely not port blocking because I am able to register whether I use port 80 or 5060.
EDIT 2:
I tried using free SIP accounts to make calls (sip2sip.info and sip.antisip.com), and I have the same problem too! As I know, sip2sip.info is using OpenSIPS too but AntiSip.com is using something like AmSIP. So the problem is with my mobile carrier?
Thank you!
If your UA can't receive calls, it means it is not reachable for signaling. In order for your UA to be reachable, it needs to register and keep the NAT mappings alive. To keep a NAT mapping alive, your UA must send keepalive to the server periodically. Another option is that the server sends keepalives to the UA but some NATs don't refresh mappings for incoming traffic.
When you solve this first issue, comes the media part where technologies like STUN, TURN and ICE will help.

XMPP Framework maximum messages received

I'm making a XMPP client and I would like if there is some timer or memory cache for messages received because i send 1000 messages to my client and the server send 1000 messages ok but my client only receive 300.
Possible Solution:
...Overcoming those limits
Every time HTTP has a solution for “fixing” XMPP.
The first two limits can be fixed by running a WebDAV server. Upload to the WebDAV server, share the link. That’s a solution everyone can do without XMPP client support. Of course, having a way to do that transparently with client and server support, with signed URLs (à la S3) would greatly improve the process.
For the connected socket problem, there’s BOSH. That’s basically running XMPP over HTTP. With the added bonus of having the server retaining the “connection” for a couple of minutes – that fixes my iPhone problem. Once I relaunch the client in the two minutes window, all the pending messages are delivered.
Your receiver is receiving only 300 messages means they might be the offline messages. If this is the case you need to increase the Per-user offline message storage limit in your admin panel.
I would like to suggest you to go for message archiving and retrieving instead of depending on offline messages.
Hope this helps you :)

Do I need to implement an XMPP server?

(newbie alert)
I need to program a multiparty communication service for a course project, and I am considering XMPP for it.
The service needs following messaging semantics:
1) server will provide a method of registering and unregistering an address such as somenode#myservice.com/SomeResource. (for now I will do it manually).
2) server will provide a method of forwarding incoming messages from, say, somenode#myservice.com/SomeResource to someothernode#myservice.com/someOtherResource, assuming that the latter is registered, and a method for removing this forwarding. (for now I will do it manually).
3) anonymous clients can send messages to, say, somenode#myservice.com/someresource (one way traffic only). If there is any forwarding setup, the message will be forwarded. Finally if the address is somenode#myservice.com/someresource is registered, the message will be stored for later delivery (or immediate if a retrieving client is online - see below). If no forwarding and unregistered, message will be silently dropped.
4) clients can connect and retrieve messages from a registered address. Exact method of authenticating clients (e.g., passwords?) is yet to be determined.
Eventually, I want to add support for clients to connect from a web browser so they can register/unregister and set/remove forwarding themselves.
Thus, the server will have to do some non-standard switching. Will I need to implement an XMPP server for this? I guess some (or all?) of this can also be done using a XMPP client bot
You might investigate whether Pub/Sub is a better fit for your problem than custom messaging semantics. If so, you may find an implementation of it in your existing XMPP server.
You could probably get away with using a message queue like ActiveMQ for the communication and Apache Camel for the routing/forwarding/processing.