openfire + xampp + Strophe not connection - openfire

I am using openfire + xampp + strophe js, when run http-bind method it will give an error, in the openfire Server->Server Settings->HTTP Binding is enabled
connection = new Strophe.Connection(BOSH_SERVICE);
var PSW = $('#pass').val();
var res = PSW.slice(basemd5enc, basemd5encsecond);
connection.connect($('#jid').val()+'#'+jid_host,res,onConnect);
When i run this code on local that time got following error:
<body><failure><not-authorized/></failure></body>

I guess you're passing wrong password here if you're using strophe Js use this code
connection = new Strophe.Connection(BOSH_SERVICE);
connection.connect(ketan#mydomain,mypassword,onConnect);
Ketan#mydomain is my jid
Ie ketan is username and mydomain is domain name
Mypassword is my openfire user password

Related

Blazor WebAssembly MQTT over websockets not working

I'm trying to implement an mqtt over websocket client subscriber in Blazor using Paho. The problem is it insists on using wss instead of ws and throws an ERR_SSL_PROTOCOL_ERROR error upon connection.
Here's a simplified code block:
var mqtt;
var host = "api.mydomainexample.com";
var port = 1884;
function onConnect(){
console.log("connected ! Now listening for messages ..");
mqtt.subscribe("someTopic");
}
function onFailure(message){
console.log("connection to host failed: " + message);
}
function onMessageArrived(msg){
var message = "Message received on topic '"+ msg.destinationName +"': "+ msg.payloadString;
console.log(message);
}
function mqttConnect() {
console.log("connecting to " + host + " ..");
mqtt = new Paho.MQTT.Client(host, port, clientid);
var options = {
timeout: 3,
onSuccess: onConnect,
onFailure: onFailure,
useSSL: false
};
mqtt.onMessageArrived = onMessageArrived;
mqtt.connect(options);
}
I copied this code into an html page created in notepad, called the function from the html body and ran the file in browser. It worked and subscribed well.
Also I added useSSL: false in the connection options although I didnt have it before but still didnt work.
here's the error I'm having from console:
WebSocket connection to 'wss://api.mydomainexample:1884/mqtt' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR
I also changed my projects launch settings so that it launches as http and not https because based on this answer, I cannot use a ws from a page loaded through https.
Any ideas ? Can't I just connect to a websocket without certificate in blazor?
Ok it turns out that when creating the blazor application, there is an option to 'configure on https' where this option causes requests redirection from http to https and consequently asks for secure wss instead of ws.
Hope this helps someone!

javax.mail: Sending without authentication hangs inside Transport.send()

I am trying to send error reports from an application using a local send-only Postfix server. The server works fine (I have tested it using both telnet and mail) but I can't get the code below to work:
Properties props = new Properties();
props.put("mail.smtp.host",host); // "localhost"
props.put("mail.smtp.port",port); // "25"
props.put("mail.smtp.auth",auth); // false
props.put("mail.smtp.starttls.enable",tls); // false
props.put("mail.smtp.ssl.enable",ssl); // false
props.put("mail.smtp.sendpartial",true);
Session session = Session.getDefaultInstance(props);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipient(Message.RecipientType.TO,new InternetAddress(to));
msg.setSubject(subject);
msg.setContent(content,"text/plain");
Transport.send(msg);
I have traced it up to the final call to send(), and it just hangs at that point -- it never returns from the call.
If I set "mail.smtp.auth" to true and replace the call to Transport.send() with this code:
Transport transport = s.getTransport("smtp");
transport.connect(host,Integer.parseInt(port,10),"foo","bar");
transport.sendMessage(msg,msg.getRecipients(Message.RecipientType.TO));
transport.close();
then it hangs inside the call to connect(). The same as true if I set "mail.smtp.auth" to false and set the username and password to null in the call to connect().
In /var/log/mail.log I see this:
connect from localhost[127.0.0.1]
and after I kill the hung process:
lost connection after CONNECT from localhost[127.0.0.1]
disconnect from localhost[127.0.0.1] commands=0/0
Can anyone see what I've done wrong here?
The problem turned out to be that the user "postfix" was being blocked by iptables. Adding an ACCEPT rule for postfix solved the problem.

strophe connect openfire error

I input a jid and pwd on a html form, and use Strophe to connect to openfire, but when I press the login button, the xmpp server response is error 302.
I enabled the option on openfire, and restarted it.
var BOSH_SERVICE = 'http://ip:7070/http-bind';
$('#btn-login').click(function() {
if(!connected) {
connection = new Strophe.Connection(BOSH_SERVICE);
connection.connect($("#input-jid").val(), $("#input-pwd").val(), onConnect);
jid = $("#input-jid").val();
}
});
It seems a little harder than to use smack in java because of the network problem?
The problem is in the uri specified in BOSH_SERVICE.
Correct uri is:
http://ip:7070/http-bind/
Pay attention to the / at the bottom of the string.

SSL options in gocql

In my Cassandra config I have enabled user authentication and connect with cqlsh over ssl.
I'm having trouble implementing the same with gocql, following is my code:
cluster := gocql.NewCluster("127.0.0.1")
cluster.Authenticator = gocql.PasswordAuthenticator{
Username: "myuser",
Password: "mypassword",
}
cluster.SslOpts = &gocql.SslOptions {
CertPath: "/path/to/cert.pem",
}
When I try to connect I get following error:
gocql: unable to create session: connectionpool: unable to load X509 key pair: open : no such file or directory
In python I can do this with something like:
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
USER = 'username'
PASS = 'password'
ssl_opts = {'ca_certs': '/path/to/cert.pem',
'ssl_version': PROTOCOL_TLSv1
}
credentials = PlainTextAuthProvider(username = USER, password = PASS)
# define host, port, cqlsh protocaol version
cluster = Cluster(contact_points= HOST, protocol_version= CQLSH_PROTOCOL_VERSION, auth_provider = credentials, port = CASSANDRA_PORT)
I checked the gocql and TLS documentation here and here but I'm unsure about how to set ssl options.
You're adding a cert without a private key, which is where the "no such file or directory" error is coming from.
Your python code is adding a CA; you should do the same with the Go code:
gocql.SslOptions {
CaPath: "/path/to/cert.pem",
}

Different smarthosts for different domains with different credentials

Hello I have two (or maybe more later) domains:
domain1
domain2
I want to configure Exim (cPanel) to use SendGrid's or Mailgun SMTP servers, currently I'm trying with this config in Exim:
**Section: TRANSPORTSTART**
domain1_smtp:
driver = smtp
hosts = smtp.mailgun.org
hosts_require_auth = smtp.mailgun.org
hosts_require_tls = smtp.mailgun.org
domain2_smtp:
driver = smtp
hosts = smtp.mailgun.org
hosts_require_auth = smtp.mailgun.org
hosts_require_tls = smtp.mailgun.org
**Section: AUTH**
domain1_login:
driver = plaintext
public_name = LOGIN
client_send = : postmaster#mg.domain1.com : password
domain2_login:
driver = plaintext
public_name = LOGIN1
client_send = : postmaster#mg.domain2.com : password
**Section: PREROUTER**
send_via_domain1:
driver = manualroute
domains = ! +local_domains
senders = *#domain1.cm
transport = domain1_smtp
route_list = "* smtp.mailgun.org::2525 byname"
host_find_failed = defer
send_via_domain2:
driver = manualroute
domains = ! +local_domains
senders = *#domain2.com
transport = domain2_smtp
route_list = "* smtp.mailgun.org::2525 byname"
host_find_failed = defer
When I'm sending email from user#domain1.com I'm getting messages delivered by postmaster#mg.domain1.com and when I'm sending from user#domain2.com I'm getting messages delivered also from postmaster#mg.domain1.com.
I want to have smarthost for every domain with different credentials. Thanks
I have these setup (VPS + WHM/cPanel + Exim + Mailgun) and after doing some online research, I've found a few helpful websites regarding this topic and managed to come out with the correct configuration. Below are the solutions that I'm currently using on my VPS and hope it will help you as well. It should solve your "via" problem and might solve the intermittent "550 5.7.1 Relaying denied" error from Mailgun as well:
Go to the "Exim Configuration Editor" in WHM. Choose "Advanced Editor" and insert the configuration below:
Section: AUTH
mailgun_login:
driver = plaintext
public_name = LOGIN
hide client_send = ": ${extract{login}{${lookup{$sender_address_domain}lsearch{/etc/exim_mailgun}{$value}fail}}} : ${extract{password}{${lookup{$sender_address_domain}lsearch{/etc/exim_mailgun}{$value}fail}}}"
Section: ROUTERSTART
mailgun:
driver = manualroute
domains = ! +local_domains
transport = mailgun_transport
route_list = "* smtp.mailgun.org::587 byname"
host_find_failed = defer
no_more
Section: TRANSPORTSTART
mailgun_transport:
driver = smtp
hosts = smtp.mailgun.org
hosts_require_auth = smtp.mailgun.org
hosts_require_tls = smtp.mailgun.org
Then create a file named /etc/exim_mailgun and insert the content similar to the structure below (Replace it with your Mailgun's domain login credentials that was verified):
domain1.com: username=postmaster#mg.domain1.com password=abcdefghi
domain2.com: username=postmaster#mg.domain2.com password=jklmnopqr