ejabberd connection for multiple resources using Strophe - xmpp

I am new in ejabberd and Strophe. I am developing web-chat application using strophe client and ejabberd xmpp server.
Connection prebind in backend:
XMPPPrebind xmppPrebind = new XMPPPrebind(boshHost, xmppDomain,
boshUri, resource, boshPort, useSsl, debug);
xmppPrebind.connect(username, password);
xmppPrebind.auth();
SessionInfo sessionInfo = xmppPrebind.getSessionInfo();
Attach connection in strophe on UI:
connection = new Strophe.Connection(BOSH_SERVICE);
connection.attach(userjid + '#' + domain, sid, rid, onConnect);
connection.addHandler(onMessage, null, 'message', null, null, null);
......
On the page load I make new ejabberd connection from back-end and get sid and rid. Attaching connection using sid and rid in strophe on UI. It is working fine, no issue.
But when user open new tab in browser for same user, its cause new ejabberd connection with new sid and rid, then the old tab getting disconnected.
How can I keep alive connection in both tabs or multiple tabs so that user can send/receive message in all tab ?
I searched on google but not found steps to enable this feature in web chat.
Also try to understand : http://xmpp.org/extensions/xep-0280.html
I am blocked here, Please help.
Thanks

You need to generate a new unique resource per browser tab. Using the same resource name will disconnect previously connected resources, by design.

Related

Failed to connect to localhost/127.0.0.1:7443

Hi i am using openfire as my im server to my mobile app client, I have added the Httpfileupload plugin to openfire and enabled the http bind settings, when I try to upload a file it shows me this error Failed to connect to localhost/127.0.0.1:7443 ,
and the servers send me this XML message <get url="https://localhost:7443/httpfileupload/45726202-5e69-4b5c-a533-00d82f6d1121/4add76e7f15b6b4f.png"/>
I’ve tried to access this uri but it doesn’t work
please help me with this issues
i am using the latest smack version and the latest openfire version also
You appear to have set up Openfire using the value 'localhost' as its XMPP domain and/or fully qualified domain name for the server that is running Openfire. This is a recipe for disaster. Openfire is broadcasting the address of the content that is managed by its HTTP File Upload plugin, and uses the value that was configured, 'localhost'. Clients, which typically run on different machines, will try to connect to this host. As they're instructed to connect to 'localhost', they'll never be able to reach Openfire.
My advise is to setup Openfire again, and use proper, network-reachable addresses for values of the XMPP domain name and FQDN (these are asked for in the second page of the setup wizard, if memory serves).

proxmox CT external vnc access

I'm creating a PAAS provider with openVZ virtual machines on proxmox.
I want to use noVNC to access the instances in another website different than proxmox console.
I used an url with this form
wss://promox_ip:8006/api2/json/nodes/node_name/openvz/instance_id/vncwebsocket?port=5900&vncticket=vnc_ticket
I'm always getting this error:`
connection closed unexpectedly.
`
note that i use a new ticket each connection.
Finally solved by adding modifications to HTTPerver.pm file under
/usr/share/perl5/PVE/
to Allow accessing novnc console when not logged in.
Then send POST resquest to
/api2/json/nodes/{node}/lxc/{vmid}/vncproxy
and get ticket and port.
Then you can connect via websocket to this link
/api2/json/nodes/{node}/lxc/{vmid}/vncwebsocket

getting SocketTimeoutException while using smack 4.1.2 in android to connect to my ejabberd server

I am trying to connect to ejabberd server using smack API 4.1.2 (no asmack) on android device. while running smackClient program , I am getting below error
java.net.SocketTimeOutException:Failed to connect to abc.example.com/182.*.*.* (on port 5222) after 30000ms,'abc.example.com:5222' failed because java.net.ConnectionException: Failed to connect to abc.example.com/182.*.*.* (on port 5222) after 30000ms
Connection to same ejabberd server using same android device is working fine using xmpp clients like xabber. so Issue is surely with client code I have written. Below is the snippet of my code
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setUsernameAndPassword(userName, password)
.setServiceName("abc.example.com")
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setSendPresence(true)
.build();
connection = new XMPPTCPConnection(config);
connection.connect();
connection.login(userName, password);
I am missing something in my client code that xabber is having so xabber connection is working from same device using same credential.
Please help
Hard to tell without real IP and names in your example. However, my best guess would be about how the address to your IP server is resolved.
There seems to be discrepancy in your example with server (example.com) and service name in your code (abc.example.com).
My guess it that your client is attempting to connect to another machine that the one the XMPP server is running on.
So, here are the things to check when you have issues with a server not replying:
Check how the address of the domain is resolved. You may need to specify another machine name that the domain. If this is a test domain, there is possibly not a DNS setup, so you may even need to specify server IP (while still configuring the client to use an XMPP domain, that's two different things).
In client, log the IP you are trying to connect to, to make sure this is the one where the server is running.
If server is not on the main domain server, you may even need to do DNS SRV record queries for XMPP C2S service.
For me , it took hours to find the solution.
I forget to turnoff the VPN application(Express VPN) .Network tunneling was the root cause .
And change the Network protocol version properties as below ,
Choose the 1st option (Obtain DNS server address automatically).
My experience: I used following code
DomainBareJid xmppServiceDomain = JidCreate.domainBareFrom("desktop-urvfr83");
//DomainBareJid xmppServiceDomain = JidCreate.domainBareFrom("192.168.1.3");
InetAddress addr = InetAddress.getByName("192.168.1.3");
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setUsernameAndPassword("alir", "111111")
.setHostAddress(addr)
.setResource("phonn")
.setXmppDomain(xmppServiceDomain)
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setPort(5222)
.build();
but it could not connect and produced timeout connection exception. When I disabled windows firewall it worked correctly and connected.

XMPP chat : Candy won't work with Ejabberd server

I want to setup a web chat client. I decided to use Candy. The XMPP server I'm using is Ejabberd. My Ejabberd server is local. The URL is :
http://localhost:5280/
Users are defined like this :
user#localhost
The thing is I can't connect to this server using Candy out of the box while I can connect to it with simple strophejs functions on my phone.
I compared the packets that were sent to the server and they are exactly the same :
On my phone using Wireshark :
The console log when I'm connecting with Candy :
The screen is pending on "Connecting..."
What can be the reason that I can't connect to the server ? Is there something I have to configure in ejabberd.cfg ?
Thanks for help
The default URL for BOSH on ejabberd is /http-bind
When configuring your BOSH client you should point to that directory on the correct web URL, not the ejabberd service root.
Using http://example.net:5280/http-bind as BOSH URL in your Web client configuration should work.

Sending e-mail and SMS from Scala using Heroku and Ubuntu server

I'm creating a simple HTTP proxy that will sit between mobile apps and a backend SOAP server. The proxy server will be wrapped in a filter that sends e-mail and sms notifications when discovering certain types of messages. I've decided to use Scala, Finagle and Heroku. My client however insists that the system must not be tied down to Heroku, if ever they decide to host on their own Ubuntu servers. So, they are skeptical of using Heroku plugins that will make it difficult to setup the same service on Ubuntu later.
If anyone can share some ideas on approaching this problem, I will really appreciate it. In particular:
Is there anything special they will need to run Finagle on Ubuntu? Can I just use SBT to get everything 'magically'?
Are there any good solutions, libraries or services out there, that allows the sending of mail or SMS in a simple and secure manner that will play well with both Heroku and Ubuntu?
Sending mail from Java typical uses system properties. How does one set this up for a remote server like Heroku?
Sending mail from Java doesn't need system properties:
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
Session session = Session.getInstance(props);
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("from#mycomp.com"));
message.setRecipients(Message.RecipientType.TO, new InternetAddress("to#mycomp.com"));
message.setSubject("Some Subject");
message.setText("Some Message");
Transport transport = session.getTransport("smtp");
transport.connect(host, port, username, password);
Transport.send(message);
Load the props and host, port, username, password out of a properties file if you like. Or out of a database.
So, sending mail is entirely independent of Ubuntu and Heroku.
Sending SMS I've done like this: http://nexmo.com/documentation/libs/index.html#java