ejabberd: Configuration for enable websocket communication for xmpp server - websocket

Im using Ejabberd 17.1.1. I need to configure my ejabberd.yml file for websocket communication. Im using strophe.js
I already had the configuration for ejabberd.yml ie,
port: 5280
ip: "::"
module: ejabberd_http
request_handlers:
"/ws": ejabberd_http_ws
"/bosh": mod_bosh
"/api": mod_http_api
## "/pub/archive": mod_http_fileserver
web_admin: true
## register: true
captcha: false
http_bind: true
tls: true
Also tried to get connection from my javascript code,
var conn = new Strophe.Connection('ws://localhost:5280/ws/', {protocol: "ws"});
conn.connect($scope.jid, $scope.password, function(status, condition) {
if (status === Strophe.Status.CONNECTED) {
...
when getting the
status
its value is 1 not 5. what is the reason? I was able to connect the same one with
http://localhost:5280/bosh/ successfully.
Can any one give the correct configuration of ejbberd.yml file and sample code snippet for connecting through websocket using strophe.js. Thanks .

Related

typescript security hotspot in environement.ts file, SonarQube

I have an environement.ts file like this:
export const environment = {
production: false,
HOST: 'http://192.192.192.1:8081/Services/api',
API_ENDPOINT: '',
API_ENDPOINT_LOGIN: '',
ASSETS_PATH: 'assets/images/',
ENV:'dev'
};
environment.API_ENDPOINT = environment.HOST + '/web/';
environment.API_ENDPOINT_LOGIN = environment.HOST + '/login/userlogin/';
SonarQube is givng Security Hotspot on this line: HOST: 'http://192.192.192.1:8081/Services/api', I am not sure what the problem/solution is. Need some help.
Thanks
Without seeing the output of SonarQube, I can't say for sure but I'm fairly confident that the issue is that you're using an http endpoint and not an https endpoint meaning that the connection would not be secured (encrypted with TLS)

Not able to check vault status, getting error checking seal status

I have enabled TLS, using the environment variable VAULT_ADDR=https://127.0.0.1:8200, but it shows some error while unsealing or even checking the vault status.
I tried changing the environment variable to VAULT_ADDR=http://127.0.0.1:8200, that time it works, but i have enabled tls in my hcl file
My hcl file
backend "file" {
path = "/home/***/vault/"
}
listener "tcp" {
address = "127.0.0.1:8200"
tls_disable = 0
tls_cert_file = "/home/***/vault/vault.crt"
tls_key_file = "/home/***/vault/vault.key"
}
Error checking seal status: Get https://127.0.0.1:8200/v1/sys/seal-status: http: server gave HTTP response to HTTPS client

Setting up ejabberd via websockets

I have an ejabberd server up and running.
I can test it via web clients and it works fine using BOSH connections.
I would like to connect to it via web sockets now, and I am not sure what I am missing for it to work, I just know it doesn't.
Here is an extract from my ejabberd.yml
hosts:
- "localhost"
- "somedomain.com"
- "im.somedomain.com"
listen :
port: 5280
ip: "::"
module: ejabberd_http
request_handlers:
"/websocket": ejabberd_http_ws
"/pub/archive": mod_http_fileserver
web_admin: true
http_bind: true
## register: true
## captcha: true
tls: true
certfile: "/etc/ejabberd/ejabberd.pem"
Now I tried to open a web socket via javascript as follows :
var ws = new WebSocket("ws://somedomain:5280/websocket/");
I get ERR_CONNECTION_TIMED_OUT in return. I have nothing within ejabberd's logs when I try to open a weksocket. I do have logs of the BOSH connections.
I am not sure if I am testing appropriately, nor if my server is setup correctly.
Any suggestion is most welcome.
Connection timeout error will throw by the server when the client does not send pong response to the server make sure you are sending the pong response.If you are using Strophe.js kindly check Handlers http://strophe.im/strophejs/doc/1.2.14/files/strophe-js.html#Strophe.Connection.addHandler
connection = new WebSocket("ws://somedomain:5280/websocket/");
//Adding ping handler using strophe connection
connection.addHandler(pingHandler, "urn:xmpp:ping", "iq", "get");
//Ping Handler Call back function
function pingHandler(ping) {
var pingId = ping.getAttribute("id");
var from = ping.getAttribute("from");
var to = ping.getAttribute("to");
var pong = strophe.$iq({
type: "result",
"to": from,
id: pingId,
"from": to
});
connection.send(pong);
return true;
}
Also, consider you are adding this configuration to your ejabberd.yml
websocket_ping_interval: 50
websocket_timeout: 60

reconcile unable to talk with Consul backend

Im trying to setup a docker container for my vault/consul but get the following error:-
2017/06/22 18:15:58.335293 [WARN ] physical/consul: reconcile unable to talk with Consul backend: error=service registration failed: Put http://127.0.0.1:8500/v1/agent/service/register: dial tcp 127.0.0.1:8500: getsockopt: connection refused
Here is my vault config file.
storage "consul" {
address = "127.0.0.1:8500"
redirect_addr = "http:/127.0.0.1:8500"
path = "vault"
scheme = "http"
}
listener "tcp" {
address = "127.0.0.1:8200"
tls_disable = 1
}
#telemetry {
# statsite_address = "127.0.0.1:8125"
# disable_hostname = true
#}
where is Consul?
This error is saying I'm trying to reach this URL: http://127.0.0.1:8500/v1/agent/service/register and can't.
This implies that either Consul isn't running, or it's running somewhere other than at http://127.0.0.1:8500
Find your consul, and then update your config to point to it.

Enable mod_http_fileserver ejabberd 17.03 windows

I currently have an ejabberd 17.03 server running on a windows machine.
I am trying to enable mod_http_fileserver on ejabberd. I used the following configuration in the listen section :
port: 5280
module: ejabberd_http
request_handlers:
"/websocket": ejabberd_http_ws
"/api": mod_http_api
"/pub/archive": mod_http_fileserver
web_admin: true
http_bind: true
## register: true
captcha: false
and in the modules :
mod_http_fileserver:
docroot: "C:\\Tech\\ejabberd-17.03\\www"
accesslog: "C:\\Tech\\ejabberd-17.03\\logs\\access.log"
directory_indices:
- "index.html"
- "main.htm"
custom_headers:
"X-Powered-By": "Erlang/OTP"
"X-Fry": "It's a widely-believed fact!"
content_types:
".ogg": "audio/ogg"
".png": "image/png"
".jpg": undefined
default_content_type: "text/html"
However, when I try to access http://localhost:5280/pub/archive, I get a 404 not found response.
Can someone help me out please ?
Thanks !

Resources